Part Number: LAUNCHXL-F28069M
Other Parts Discussed in Thread: C2000WARE
Hello! I'm wondering if I set up this simple UART program correctly.
All I'd like to do is receive an interrupt when I receive something, and store what I receive in an array. I'll just be receiving simple strings such as 'Go', 'Stop', 'Route 1', 'Route 2' which I will parse.
I'll be running at 9600 BAUD, half duplex (only need to receive), I don't think I need FIFO (still not entirely sure what it's for!).
Here's what I came up with starting from an example project:
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#define CPU_FREQ 90E6
#define LSPCLK_FREQ CPU_FREQ/4
#define SCI_FREQ 100E3
#define SCI_PRD (LSPCLK_FREQ/(SCI_FREQ*8))-1
Uint16 RXParseData[[256]; // Received data for SCI-A
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2806x_SysCtrl.c file.
InitSysCtrl();
// SET UP UART RX PIN -> function: void InitScibGpio()
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0; // Enable pull-up for GPIO19 (SCIRXDB)
/* Set qualification for selected pins to asynch only */
// Inputs are synchronized to SYSCLKOUT by default.
// This will select asynch (no qualification) for the selected pins.
GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3; // Asynch input GPIO19 (SCIRXDB)
/* Configure SCI-B pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be SCI functional pins.
GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 2; // Configure GPIO19 for SCIRXDB operation
EDIS;
// END SET UP UART RX PIN
SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0001; // enable RX, SW RESET,
// Disable TX, RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.bit.RXBKINTENA =1; // enable receiver interrupt
SciaRegs.SCIHBAUD = 0x0000;
SciaRegs.SCILBAUD = SCI_PRD; //9600 baud
SciaRegs.SCICTL1.all =0x0021; // Relinquish SCI from Reset
// END function
}
////////////////////////////// INTERRUPT SERVICE ROUTINE////////////////////////// Is this the right one?
// INT9.3
__interrupt void SCIRXINTB_ISR(void) // SCI-B
{
Uint16 i = 0;
while (i != NULL)
{
RXParseData[i]=SciaRegs.SCIRXBUF.all; // Read data
i++;
}
// To receive more interrupts from this PIE group, acknowledge this interrupt
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
}
Thanks!
