Other Parts Discussed in Thread: TMS320F28377S
Hi,
after having changed my launchpad to run on flash instead of ram, I found a new problem in the UART communication using SCI. I want to send over a test string character by character. This string being "abcdefghijk". However, when I set my receiving end to the same baud rate, I get a sequence of wrong characters. When just sending 1 character at a time, for example 'a' I still get wrong bytes at my receiving end.
When sending 1 string of "abcdefhijk" the receiving end gets "▒xx▒x▒x▒x<▒x▒x▒x▒x<▒▒x▒x▒". This was received by using putty. (I also tried screen to record using a raspberry pi)
I have checked on the clock frequency and the divider of the baudrate. I want to get 1MBaud, with a clk of 200MHz this means that I should have a divider of 24. I also have tried a baudrate of 115200. Next to that I also tried if there was any difference on running the code from flash or ram, this didn't seem to make a difference at all.
I also tried to see what happens on a linux device which is recording. So I tried to find the baudrate of the signal accoring to a linux command "stty". This reported that there should be a baudrate of 9600. When I tried to record on this baud rate no date was to be found.
my setup:
- Launchpad XL TMS320F28377S
- connection via debug cable
- 200MHz clock
- 24 clock divider
part from main to init the sci
void initSCIA(void) {
//configure GPIO
//Pins - see launchpad schematic
//84 - transmitter port - output
//85 - receiver - input
//Principle - see reference manual
//Registers - see reference manual
//Options - see specification manual
EALLOW;
//connection function
GpioCtrlRegs.GPCMUX2.bit.GPIO84 = 1;
GpioCtrlRegs.GPCMUX2.bit.GPIO85 = 1;
GpioCtrlRegs.GPCGMUX2.bit.GPIO84 = 1;
GpioCtrlRegs.GPCGMUX2.bit.GPIO85 = 1;
//async interface
GpioCtrlRegs.GPCQSEL2.bit.GPIO84 = 3;
EDIS;
//configure SCIA
//1 stop bit, no loopback, no parity, 8 bit char, idle-line protocol
SciaRegs.SCICCR.all = 0x0007;
//unit in software reset, disable RX ERR, SLEEP, TXWAKE, enable TX, RX
SciaRegs.SCICTL1.all = 0x0003;
SciaRegs.SCICTL2.bit.TXINTENA = 1;
SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
//216 - 115200 baud - 1M152 bit/second, LSPCLK = 200MHz
//24 - 1000000 baud - 10M bit/second, LSPCLK = 200MHz
//divider = LSPCLK/(SCIBaudRate) - 1
SciaRegs.SCIHBAUD.all = 0x0000;
SciaRegs.SCILBAUD.all = 24; //216
//SciaRegs.SCILBAUD.all = 216;
SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
}
Part from scio_io.c
int SCI_write(const char * buf, unsigned count)
{
uint16_t writeCount = 0;
uint16_t * bufPtr = (uint16_t *) buf;
if(count == 0) {
return (0);
}
while(writeCount < count){
while(!SciaRegs.SCICTL2.bit.TXRDY);
SciaRegs.SCITXBUF.all = *bufPtr;
writeCount++;
bufPtr++;
}
return (writeCount);
}
Part from main, used to call sci functions
char returnString[20];
char testReadValue = 0x61;
int i;
for(i = 0; i<10; i++){
returnString[i] = i+testReadValue;
}
while(1){ SCI_write(&returnString[0], 10); //reply with received byte DELAY_US(50000); }