Is it possible to configure my F28335 board to transmit 7 bits over a serial connection with dynamic headers with the Target Support Package TC2 (R2008b)?

2 views (last 30 days)
Here is what I would like to do:
1. Use TC2 toolbox to communicate with the motor driver whose communications parameters are serial RS232 with 9600 baud rate, 7 data bits, even parity and 1 stop bit but the F28335 setup only allows to set 8 data bits.
2. Create a conversion block that will send a header byte of !A when the incoming value is greater than 0 and !a when it is less than or equal to zero.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 15 Jun 2021
Edited: MathWorks Support Team on 21 Jun 2021
Please see the attached Model file and PDF which describes the following steps with additional screen shots
Configuring the SCI serial interface:
The C2000 target preferences block contains many of the configurations for the SCI peripherals.
1. Drag a Target Preferences block from the Target Support Package TC2 / C2000 Target Preferences library into a model.
When you drag the Target Preferences block into the model, it will ask you if you would like to configure the model for code generation for the TI C2000. I generally click yes, unless I have already set-up the model configuration for code generation.
2. Double click on the Target Preferences block to open the Target Preferences dialog box.
3. Modify the peripheral configurations by clicking on the Peripherals tab in the dialog box
4. Select SCI_A from the list of peripherals on the left-hand side of the dialog.
5. Change the appropriate property settings. All of them except the number of data bits can be set here.
Setting the Data Bits:
Setting the number of data bits will require some custom code to be included in the system initialization function in the generated code. The Character Length bits field in the Target Preferences block for peripheral SCI_A should set this value, but the dialog only allows for 8-bits.
1. Add a System Initialize custom code block from the Real-Time Workshop Custom Code library to the model.
2. Double click on the System Initialize block in the model to open the custom code dialog.
3. Add the following code to the System Initialize Function Execution Code field:
EALLOW;
SciaRegs.SCICCR.bit.SCICHAR = 6; //Character length
EDIS;
4. Click OK.
This overwrites the original configuration setting for the Character length bits field for the SCI_A peripheral in the Target Preferences block.
For more information on serial interface configurations, please refer to the Texas Instrument documentation for the SCI peripheral, literature number SPRU051B at the following web address:
Adding Dynamic Headers to Transmitted Data:
In order to transmit a piece of data with the header !A if the data is greater than 0, and the header !a if it is less than 0, we need to:
1. Test the data value
2. Determine which header to transmit with the data value
3. Concatenate the header to the data value
4. Transmit the new data value
The attached model provides an example of how to perform this. Notice the Header and Footer parameters of the SCI blocks are all set to empty strings. The header is added outside the SCI blocks.
Testing the Generated Code:
The attached model uses a serial loopback to test the serial communication channels. A number of global variables are included to facilitate the monitoring of values transmitted and received using the Watch Window in Code Composer Studio.
The global variables are:
· Transmit_Value
· Receive_Value
· New_Transmit_Value
It is also easier to test with a reduced number of bits in the character length for the Serial Configuration channel. That is, set:
SciaRegs.SCICCR.bit.SCICHAR = 3;
in the initialization custom code block.
When the transmit value exceeds the number of bits allowed by the serial channel, the receive value will be truncated, and reset to 0.

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2008b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!