Component: API (BL0032) (API Slave Devices)
Author | Matrix TSL |
Version | 2.1 |
Category | API Slave Devices |
Contents
- 1 API (BL0032) component
- 2 Component Source Code
- 3 Detailed description
- 4 Examples
- 5 Macro reference
- 5.1 ADCSample12
- 5.2 ADCSample8
- 5.3 ADCSampleArray10
- 5.4 ADCSampleArray8
- 5.5 ADCSampleAverage10
- 5.6 ADCSampleAverage8
- 5.7 ADCSetPrechargeTime
- 5.8 ADCSetReferenceVoltage
- 5.9 I2CInitialise
- 5.10 I2CReceive
- 5.11 I2CRestart
- 5.12 I2CSend
- 5.13 I2CStart
- 5.14 I2CStop
- 5.15 I2CTransInit
- 5.16 I2CTransReceive
- 5.17 I2CTransSend
- 5.18 IOGetInputPin
- 5.19 IOSetOutputPin
- 5.20 Initialise
- 5.21 PWMDisable
- 5.22 PWMEnable
- 5.23 PWMSetDuty
- 5.24 PWMSetPrescaler
- 5.25 RegisterRead
- 5.26 RegisterWrite
- 5.27 SPIInitialise
- 5.28 SPIPrescaler
- 5.29 SPITransfer
- 5.30 SPITransferTrans
- 5.31 UARTBaud
- 5.32 UARTCheckRX
- 5.33 UARTInitialise
- 5.34 UARTReceive
- 5.35 UARTSend
- 6 Property reference
API (BL0032) component
Connects to an BL0032 dsPIC running the API Firmware allowing the board to become a slave to the Flowcode Embedded simulation or Flowcode App Developer. Supports: Digital IO / ADC / I2C / SPI / UART / PWM See Flowcode Help Wiki for firmware.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_BL0032_API_Comp.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_BL0032_API_Comp.fcfx
Detailed description
The App Developer (BL0032 dsPIC E-Block) component allows an BL0032 dsPIC E-block board to be controlled from within the Flowcode simulation runtime.
To allow Flowcode to communicate and control the Arduino Uno hardware the board must first be pre-programmed with dedicated firmware.
The firmware hex file and Flowcode source project can be downloaded from here.
BL0032 dsPIC App Developer Firmware
More information about the workings of the firmware project can be found on the FiniteStateMachine page.
The USB should be connected to the Target port on the E-block board to allow Flowcode to communicate with the Target microcontroller.
The COM port to the E-block hardware is selected via the SCADA_BL0032 component COM port property.
When building the component into a App Developer project remember to expose the COM port property to allow the end user to select the correct port for the hardware.
The console window can display data in two modes which is set via a component property.
- fixed statistics showing IO / ADC inputs / PWM
- scrolling log showing all commands and returns
Examples
Pin Mapping
Here is a table showing how the slave digital pins are mapped on the device.
App Developer Slave Digital Pin | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
Device Port Pin | B0 | B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 | B9 | B10 | B11 | B12 | B13 | B14 | B15 | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | E0 | E1 | E2 | E3 | E4 | E5 | E6 | E7 | F0 | F1 | F3 | F4 | F5 | C13 | C14 | D8 | D9 | D10 | D11 | G6 | G7 | G8 | G9 |
Here is a table showing how the slave analogue pins are mapped on the device.
App Developer Slave Analogue Pin | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Device Port Pin | B0 | B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 | B9 | B10 | B11 | B12 | B13 | B14 | B15 | E0 | E1 | E2 | E3 | E4 | E5 | E6 | E7 |
Here is a table showing how the slave peripheral pins are mapped on the device.
App Developer Slave Peripheral Pin | I2C 0 SDA | I2C 0 SCL | I2C 1 SDA | I2C 1 SCL | SPI 0 MOSI | SPI 0 MISO | SPI 0 SCK | SPI 1 MOSI | SPI 1 MISO | SPI 1 SCK | SPI 2 MOSI | SPI 2 MISO | SPI 2 SCK | SPI 3 MOSI | SPI 3 MISO | SPI 3 SCK | UART 0 RX | UART 0 TX | UART 1 RX | UART 1 TX | UART 2 RX | UART 2 TX | UART 3 RX | UART 3 TX |
Device Port Pin | D9 | D10 | F4 | F5 | D3 | D4 | D5 | G8 | G7 | G6 | E0 | E1 | E2 | F3 | F4 | F5 | F0 | F1 | D0 | D1 | G9 | G8 | G7 | G6 |
App Developer Slave Peripheral Pin | PWM 0 | PWM 1 | PWM 2 | PWM 3 | PWM 4 | PWM 5 | PWM 6 | PWM 7 | PWM 8 | PWM 9 | PWM 10 | PWM 11 | PWM 12 | PWM 13 | PWM 14 | PWM 15 |
Device Port Pin | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | F0 | F1 | F3 | F4 | F5 | E0 | E2 | E4 |
Macro reference
ADCSample12
![]() |
ADCSample12 |
Reads the voltage present on an Analog pin as an 12-bit value range 0-4095 | |
![]() |
ADCChannel |
Range: 0-31 ... Channels 16-23 unimplemented | |
![]() |
Return |
ADCSample8
![]() |
ADCSample8 |
Reads the voltage present on an Analog pin as an 8-bit value range 0-255 | |
![]() |
ADCChannel |
Range: 0-31 ... Channels 16-23 unimplemented | |
![]() |
Return |
ADCSampleArray10
ADCSampleArray8
ADCSampleAverage10
ADCSampleAverage8
ADCSetPrechargeTime
ADCSetReferenceVoltage
![]() |
ADCSetReferenceVoltage |
Specified the reference setting for ADC reads. | |
![]() |
RefType |
0=AREF, 1=VCC, 3=Internal 1.1V | |
![]() |
Return |
I2CInitialise
![]() |
I2CInitialise |
Initialsie the I2C module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Baud |
0=100KHz, 1=400KHz, 2=1MHz | |
![]() |
Return |
I2CReceive
![]() |
I2CReceive |
Receive a byte using the I2C bus | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Last |
Last byte to receive: Range 0-1 | |
![]() |
Return |
I2CRestart
![]() |
I2CRestart |
Put the I2C Module into Restart mode | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
I2CSend
![]() |
I2CSend |
Transmit a byte using the I2C bus | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
DataOut |
![]() |
Return |
I2CStart
![]() |
I2CStart |
Put the I2C Module into Start mode | |
![]() |
Channel |
Channel Index: Range 0 - I2C Bus Count - 1 | |
![]() |
Return |
I2CStop
![]() |
I2CStop |
Put the I2C Module into Stop mode | |
![]() |
Channel |
![]() |
Return |
I2CTransInit
I2CTransReceive
I2CTransSend
IOGetInputPin
![]() |
IOGetInputPin |
Sets the selected digital pin to an input and reads the input state. | |
![]() |
Pin |
Range: 0-47 ... Pin 34 unimplemented | |
![]() |
Return |
IOSetOutputPin
![]() |
IOSetOutputPin |
Sets the selected digital pin to an output and assigns the output state. | |
![]() |
Pin |
Range: 0-47 ... Pin 34 unimplemented | |
![]() |
State |
Range: 0-1 | |
![]() |
Return |
Initialise
![]() |
Initialise |
Initialise the comms to the Arduino board ready for commands to be sent. | |
![]() |
Return |
PWMDisable
![]() |
PWMDisable |
Disable a PWM output | |
![]() |
Channel |
Range: 0-15 | |
![]() |
Return |
PWMEnable
![]() |
PWMEnable |
Enable a PWM output | |
![]() |
Channel |
Range: 0-15 | |
![]() |
Return |
PWMSetDuty
![]() |
PWMSetDuty |
Sets the duty for the PWM output | |
![]() |
Channel |
Range: 0-15 | |
![]() |
Duty |
![]() |
Return |
PWMSetPrescaler
![]() |
PWMSetPrescaler |
Sets the prescaler for the PWM output | |
![]() |
Channel |
Range: 0-15 | |
![]() |
Prescaler |
![]() |
Period |
Default 255 | |
![]() |
Return |
RegisterRead
![]() |
RegisterRead |
Read one of the registers on-board the device | |
![]() |
RegisterAddress |
The address of the register | |
![]() |
Return |
RegisterWrite
![]() |
RegisterWrite |
Writes to one of the registers on-board the device | |
![]() |
RegisterAddress |
The address of the register | |
![]() |
Data |
The data value to assign to the register | |
![]() |
Return |
SPIInitialise
![]() |
SPIInitialise |
Initialsie the SPI module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
Return |
SPIPrescaler
![]() |
SPIPrescaler |
Modify the speed of the SPI bus | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
Prescaler |
Range: 0-2 | |
![]() |
Return |
SPITransfer
![]() |
SPITransfer |
Transfer a byte using the SPI bus | |
![]() |
Channel |
Channel Index: Range 0 - SPI Bus Count - 1 | |
![]() |
DataOut |
![]() |
Return |
SPITransferTrans
UARTBaud
UARTCheckRX
![]() |
UARTCheckRX |
Check to see if the UART module has received any data | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
UARTInitialise
![]() |
UARTInitialise |
Initialise the UART module ready for communications | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
UARTReceive
![]() |
UARTReceive |
Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Return |
UARTSend
![]() |
UARTSend |
Send a byte via the UART module | |
![]() |
Channel |
Channel Index: Range 0 - UART Bus Count - 1 | |
![]() |
Data |
Data Byte to send. Range: 0-255 | |
![]() |
Return |