Part Number: TMS320F28379D
Hello Everyone,
I am trying to receive array from docklight software But, the last byte of array is not receiving initially. baud rate is 9600, parity none,stop bit 1.
For ex.
if I send "Hello" from docklight software. The microcontroller received "Hell" only.
again if I send "Hello" controller receive "oHell".
it means the last byte of array will receive with second array. I have attached my code for your ref.
#include "F28x_Project.h"
// Globals
//So, Tpwm = (2001) / (12.5M) = 0.00016
//Fpwm = 1/Tpwm = 1/0.00016 = 6.246 kHz
//so to find count from freq
// count (tbprd)= 12.5MHz/ freq .... where tbprd=max+min
char ReceivedChar[1000];
char *msg;
int j;
// Function Prototypes
void Scic_echoback_init(void);
void Scic_xmit(int a);
void Scic_msg(char *msg);
interrupt void scicRxFifoIsr(void);
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xD_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initialize GPIO:
// This example function is found in the F2837xD_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
InitGpio();
// For this example, only init the pins for the SCI-A port.
// GPIO_SetupPinMux() - Sets the GPxMUX1/2 and GPyMUX1/2 register bits
// GPIO_SetupPinOptions() - Sets the direction and configuration of the GPIOS
// These functions are found in the F2837xD_Gpio.c file.
GPIO_SetupPinMux(139, GPIO_MUX_CPU1, 6);
GPIO_SetupPinOptions(139, GPIO_INPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(56, GPIO_MUX_CPU1, 6);
GPIO_SetupPinOptions(56, GPIO_OUTPUT, GPIO_ASYNC);
// Enable PWM1, PWM6
CpuSysRegs.PCLKCR2.bit.EPWM1=1;
CpuSysRegs.PCLKCR2.bit.EPWM6=1;
// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
// These functions are in the F2837xD_EPwm.c file
InitEPwm1Gpio();
InitEPwm6Gpio();
// Step 3. Clear all interrupts and initialize PIE vector table:
// 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.
// This function is found in the F2837xD_PieCtrl.c file.
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).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in F2837xD_DefaultIsr.c.
// This function is found in F2837xD_PieVect.c.
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.SCIC_RX_INT = &scicRxFifoIsr;
EDIS; // This is needed to disable write to EALLOW protected registers
// To ensure precise timing, use write-only instructions to write to the entire
// register. Therefore, if any of the configuration bits are changed in
// ConfigCpuTimer and InitCpuTimers (in F2837xD_cputimervars.h), the below
// settings must also be updated.
CpuTimer0Regs.TCR.all = 0x4001;
// Enable global Interrupts and higher priority real-time debug events:
IER = M_INT8 ; // For ADCA0,EPWM1 and for SCIC_RX
// Enable interrupts for SCI/UART required for this example
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER8.bit.INTx5 = 1; // PIE Group 8, INT1 SCI RX.. see page no. 96
Scic_echoback_init(); // Initialize SCI for echoback
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global real-time interrupt DBGM
while(1)
{
}
}
// Scic_echoback_init - Test 1, SCIC DLB, 8-bit word, Baud rate 0x000F, default,1 STOP bit, no parity
void Scic_echoback_init()
{
// Note: Clocks were turned on to the Scic peripheral
// in the InitSysCtrl() function
ScicRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScicRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScicRegs.SCICTL2.all = 0x0003;
// ScicRegs.SCICTL2.bit.TXINTENA = 1;
ScicRegs.SCICTL2.bit.RXBKINTENA = 1;
//Scic at 9600 baud
//pllsysclk=100MHZ by sysctrl register
//sysclk is 100MHz
//lspclk=100/4=25Mhz.
//baud=LSPCLK/(9600 * 8) - 1
//LSPCLK uses a /4 divider by default
ScicRegs.SCIHBAUD.all = 0x0001;
ScicRegs.SCILBAUD.all = 0x0045;
ScicRegs.SCIFFTX.all = 0xE040; //0xE040
ScicRegs.SCIFFRX.all = 0x0022; //0x2044;
ScicRegs.SCIFFCT.all = 0x0;
ScicRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
ScicRegs.SCIFFRX.bit.RXFIFORESET = 1;
}
// Scic_xmit - Transmit a character from the SCI
void Scic_xmit(int a)
{
while (ScicRegs.SCIFFTX.bit.TXFFST != 0) {}
ScicRegs.SCITXBUF.all =a;
}
// Scic_msg - Transmit message via Scic
void Scic_msg(char * msg)
{
int i;
i = 0;
while(msg[i] != '\0')
{
Scic_xmit(msg[i]);
i++;
}
}
// scicRxFifoIsr - Scic Receive FIFO ISR
interrupt void scicRxFifoIsr(void)
{
while(ScicRegs.SCIFFRX.bit.RXFFST == 0) { } // wait for empty state
ReceivedChar[j] = ScicRegs.SCIRXBUF.all;
j++;
ScicRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag
ScicRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag
PieCtrlRegs.PIEACK.all|=M_INT8; // Issue PIE ack
}