This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi All,
I am using SCI for communication with the encoder.
Currently, after changing from the SCIC module to the SCID module, I am unable to change the baud rate.
After setting SCID to 115200 bps in sysconfig, I am trying to change it to 2.5 MHz with the following function.
EALLOW; // This is needed to write to EALLOW protected registers
ClkCfgRegs.LOSPCP.bit.LSPCLKDIV = 0; // change for SCI
EDIS; // This is needed to disable write to EALLOW protected registers
ScidRegs.SCIHBAUD.bit.BAUD = 0x00;
ScicRegs.SCILBAUD.bit.BAUD = 0x09; // 9 (0x0009) = 2,500,000bps
However, I cannot communicate with the encoder properly.
If I use ScicRegs instead of ScidRegs, the baud rate seems to change correctly.
Are there any settings needed to change from a SCIC module to a SCID module?
Also, are there any settings needed to change the baud rate?
Best Regards,
Ito
Hi Ito,
When you use SCIC vs SCID, can you check the register values for the SCI module being used when you run your project as well as the LOSPCP value (using CCS "Registers" view window with continuous refresh on). Are there any differences in SCI configuration or LSPCLK divider value between SCIC vs SCID?
Best Regards,
Allison
Hi Allison,
Thank you for your reply.
The current SCID setup is sysconfig as shown in the picture, and the function I sent you before.
When we used SCIC in the past, we used only sysconfig to set it up, and the PinMux in the picture is set to SCIC.
In other words, the difference when changing from SCIC to SCID is the PinMux configuration and,
only the added functions.
I can't find any reason why I can't change the baud rate from 115200 bps to 2.5 Mbps.
Is there any cause for this?
Best Regards,
Ito
Hi Ito,
Do you mean when you try to type 2.5Mbps into the sysconfig baud rate, it doesn't let you? Or just that you are seeing the incorrect SCI rate output?
Can you check the registers (using register view window in CCS with continuous refresh on) and/or check the sysconfig generated code (using the <> arrows in the upper right hand corner and looking at board.c) to see if the LOSPCP divider (for LSPCLK which is the clock source for SCI) and SCI baud rate register values are as expected?
Best Regards,
Allison
Hi Allison,
Thank you for your reply.
No, the default setting in sysconfig is 115200 bps.
After that, I set it to 2.5 Mbps with the function I sent you before.
When I was using the SCIC module, I set the baud rate to 115200 bps in sysconfig and did not change the baud rate after that.
This is my customer's code and I will check it as soon as I receive it.
Best Regards,
Ito
Hi Ito,
The functions (that you sent previously) implemented before or after Board_init()?
Calling Board_init() later in your main() will implement the settings from Sysconfig and overwrite existing configurations in the process so that is something to check.
But yes, let me know if the customer/you can check the registers as I mentioned when you are able.
Best Regards,
Allison
Hi Allison,
Thank you for your reply.
Yes, the function is written after Board_init().
So there does not seem to be any overwriting.
I have obtained the customer's file, please check the Friendship.
Best Regards,
Ito
Hi Ito,
Just accepted the friend request. Please allow for 1-2 days for me to take a look at the code. Are you also scoping the SCI pins in each case?
An another note, I also wanted to share with you this FAQ that can help with SCI debug if you have not already seen it: https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1031947/faq-my-c2000-sci-is-not-transmitting-and-or-receiving-data-correctly-how-do-i-fix-this
Best Regards,
Allison
Hi Allison,
Thank you for checking the code!
This is a customer application so the scope is not done.
I will give the customer the FAQ.
Best Regards,
Ito
Hi Ito,
Took a look through some of the code and have some follow up questions to better understand the situation:
For SCI initialization, please take a look at the SCI FAQ I sent as it walks you through how you should be initializing SCI in a specific order. I don't see this flow happening in the user_inital_SCI() in ti_unit_SCI.c file. Also I see three different instances of SCI in the project (SCIA, SCIB, SCID) - are you having trouble with all three? Or only SCID?
I also wanted to clarify what your specific issue is: Is it that you have tried running the code and are actually seeing an incorrect baud rate from the SCI? How are you checking what the baud rate is? Are you watching the register values for LOSPCP as well as SCIHBAUD and SCILBAUD and seeing incorrect values when you run the code?
What did you originally mean when you say you "cannot communicate with the encoder properly"? Does this mean you are able to run the application code but are receiving incorrect data? Or seeing some other error?
Best Regards,
Allison
Hi Allison,
Thank you for your reply.
The FAQ is currently being reviewed.
The only problem is the SCID.
LOSPCP was set correctly, but SCILBAUD had 0xD8 instead of 0x09.
In other words, the baud rate is still at the default setting of 115200.
The meaning of "unable to communicate with encoder" is that the code can be executed,
but the baud rate cannot be changed and communication is not possible.
Best Regards,
Allison
Hi Ito,
Good that LOSPCP is getting set up ok. Let me know if the FAQ is helpful at all.
My first suggestion is to edit your SCI initialization function to add an SCI software reset around your changing the SCI baud registers. You can do so by setting SCICTL1.SWRESET to 0, then configure your SCI baud regs, then set SCICTL1.SWRESET to 1 to relinquish the SCI module from reset. Please let me know if this changes. Are you configuring anything else SCI-wise outside of sysconfig? or only the SCI baud?
If this doesn't work, I have few more questions for you:
user_initial_SCI(void)
, correct? ScidRegs.SCIHBAUD.bit.BAUD = 0x00;
ScidRegs.SCILBAUD.bit.BAUD = 0x09; // 9 (0x0009) = 2,500,000bps
If you haven't already, I would also suggest the customer refer to the SCI examples in C2000Ware as they could be very helpful to compare SCI initialization/code to (driverlib examples at {C2000Ware}\driverlib\f2838x\examples\c28x\sci and a bitfield example at {C2000Ware}\device_support\f2838x\examples\cpu1\sci).
Best Regards,
Allison
Hi Allison
Thank you for your reply.
I will answer the questions.
1,Confirming
2,After setting the SCID module baud rate to 115200 in Sysconfig
Because I need to set the SCID baud rate to 2.5Mbps.
Sysconfig can only do the initial setting, right?
3,Yes, that is correct.
4,We have confirmed that the baud rate is set to 2.5 Mbps, but data is not received and seems to be overwritten to 115200.
Let me explain the current situation.
1,I was able to set the data to 2.5Mbps.
2,However, even after executing the code, the data could not be received and the baud rate was found to be overwritten to the original 115200 bps.
3,The microcontroller we are developing this time was F28384D, not F28386S.
It seems that the customer had not been able to confirm this.
It seems that the software of F28388D used in the past is used in F28384D as it is. This should not be a problem since this is a member of the F2838x family.
4,All software is written to CPU1 of F28384D.
5,Even though SWRESET is used to prevent overwriting, the software can be temporarily set to 2.5 Mbps, but later it seems to be rewritten to 115200 bps.
The customer thinks it is caused by the CCS or the command file.
Can you help us figure out what it is?
Best Regards,
ito
Hi Ito,
You are correct that SysConfig is called to set up initial configurations (via the board_init() function). After this, any other code/configurations you implement will overwrite your SysConfig configurations. So if you are setting the SCI baud rates to different values later, then this should overwrite the 115200 SysConfig settings.
Is the customer able to identify where/when the baud rate values are changes? Stepping through the code while watching those registers should allow the customer to figure this out and see when those SCI baud register values are changing and if they are changing to the correct values- please let me know if they are able to do so.
Best Regards,
Allison
Hi Allison,
Using Allison's advice, I found the cause after debugging with a customer.
The cause was that the USB driver was using asynchronous serial, and only the communication settings were using the SCI API,
The USB driver was using asynchronous serial, and only the communication settings were using SCI's API.
The SCI configuration API was executed after the user init process, and whenever there was a request to change a setting from a higher-level USB device, it was initialized through the SCI configuration.
Therefore, we changed the configuration to use SCIC for USB configuration and SCID for encoder communication, and the malfunction was eliminated.
Thanks to Allison, we were able to solve the problem.
Thank you very much.
Ito