Other Parts Discussed in Thread: C2000WARE
Hi,
I am trying to implement SCI by just only checking TXRDY and RXRDY flag bit. So I am not using TX and Rx interrupt. I set baud rate at 9600 but data is not coming correctly.
I am unable to find what is wrong in code. I have attached my code and terminal output .
Please help me to overcome this issue.
Regards,
Deepak Agrawal
#include "F28x_Project.h"
//#define LSPCLK 25E6
//#define Baud_rate 9600
//#define Divider (uint16_t)((LSPCLK / (Baud_rate * 8U)) - 1U)
//
// Main
//
void initSCIAEchoback(void);
void transmitChar(uint16_t a);
void transmitMessage(unsigned char *msg);
void main(void)
{
uint16_t ReceivedChar;
unsigned char *msg;
// Initialize device clock and peripherals
InitSysCtrl();
// Initialize GPIO
InitGpio();
// GPIO_SetupPinMux() - Sets the GPxMUX1/2 and GPyMUX1/2 register bits
// GPIO_SetupPinOptions() - Sets the direction and configuration of GPIOs
GPIO_SetupPinMux(28, GPIO_MUX_CPU1, 1);
GPIO_SetupPinOptions(28, GPIO_INPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(29, GPIO_MUX_CPU1, 1);
GPIO_SetupPinOptions(29, GPIO_OUTPUT, GPIO_ASYNC);
// Disable CPU interrupts
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR)
InitPieVectTable();
initSCIAEchoback();
msg = "\r\n\n\nHello World!\0";
transmitMessage(msg);
msg = "\r\nYou will enter a character, and the DSP will echo it back!\n\0";
transmitMessage(msg);
for(;;)
{
msg = "\r\nEnter a character: \0";
transmitMessage(msg);
// wait for character
while(!SciaRegs.SCIRXST.bit.RXRDY)
{
}
ReceivedChar = SciaRegs.SCIRXBUF.all;
msg = " You sent: \0";
transmitMessage(msg);
transmitChar(ReceivedChar);
}
}
void initSCIAEchoback(void)
{
/* Communication control register SCICCR*/
SciaRegs.SCICCR.all = 0x0003; // one stop bit; no parity bit;
// loop back test mode disabled; idle-line mode;
// 8 character length
/* control register 1 */
SciaRegs.SCICTL1.all = 0x0003; // Tx and Rx enabled;
// wake and sleep disabled
/* Baud rate registers */
SciaRegs.SCIHBAUD.all = 0x0001;
SciaRegs.SCILBAUD.all = 0x0044;
SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
}
void transmitChar(uint16_t a)
{
while(!SciaRegs.SCICTL2.bit.TXRDY)
{
}
SciaRegs.SCITXBUF.all = a;
}
void transmitMessage(unsigned char *msg)
{
int i;
i = 0;
while(msg[i] != '\0')
{
transmitChar(msg[i]);
i++;
}
}