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.

f28069 SCIA interrupt issue

Other Parts Discussed in Thread: DRV8301, DRV8301-69M-KIT, TMS320F28069M, MOTORWARE

Hi,

i am working with the 28069M MCU and the DRV8301 evaluation board and have been trying to receive SCI data via an interrupt.
However, after the interrupt is triggered once, it doesn't trigger again, although data is still sent.
I've already tried out the SCI echoback example and everything worked fine.
Another interesting aspect is that, although the baud rate is set to 9600, I always receive the data on my PC at a higher baud rate, in this case at 57600.

Thank you for any help in advance.


I'm attaching the relevant code lines below:

Init part:

// -------------- Initialize handles --------------//

    MeinGPIOHandle = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
    MeinADCHandle = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
    MeinCLKHandle = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
    MeinTIMERHandle = TIMER_init((void *)TIMER0_BASE_ADDR, sizeof(TIMER_Obj));
    MeinTIMER1Handle = TIMER_init((void *)TIMER1_BASE_ADDR, sizeof(TIMER_Obj));
    MeinTIMER2Handle = TIMER_init((void *)TIMER2_BASE_ADDR, sizeof(TIMER_Obj));
    MeinFLASHHandle = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
    MeinPLLHandle = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
    MeinCPUHandle = CPU_init((void *)NULL, sizeof(CPU_Obj));
    MeinWDOGHandle = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));
    MeinSCIHandle = SCI_init((void *)SCIA_BASE_ADDR, sizeof(SCI_Obj));
    MeinPIEHandle = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));

// -------------- Initialize GPIO --------------//

 GPIO_setPullup(MeinGPIOHandle, GPIO_Number_28, GPIO_Pullup_Enable);
 GPIO_setPullup(MeinGPIOHandle, GPIO_Number_29, GPIO_Pullup_Disable);
 GPIO_setQualification(MeinGPIOHandle, GPIO_Number_28, GPIO_Qual_ASync);
 GPIO_setMode(MeinGPIOHandle, GPIO_Number_28, GPIO_28_Mode_SCIRXDA);
 GPIO_setMode(MeinGPIOHandle, GPIO_Number_29, GPIO_29_Mode_SCITXDA);

// -------------- Initialize SCI --------------// 

 CLK_enableSciaClock(MeinCLKHandle);
 SCI_enableTx(MeinSCIHandle);
 SCI_enableRx(MeinSCIHandle);
 SCI_setMode(MeinSCIHandle, SCI_Mode_IdleLine);
 SCI_disableParity(MeinSCIHandle);
 SCI_disableLoopBack(MeinSCIHandle);
 SCI_disableRxErrorInt(MeinSCIHandle);
 SCI_setNumStopBits(MeinSCIHandle, SCI_NumStopBits_One);
 SCI_setCharLength(MeinSCIHandle, SCI_CharLength_8_Bits);
 SCI_enableRxInt(MeinSCIHandle);
 SCI_disableTxInt(MeinSCIHandle);
 SCI_setBaudRate(MeinSCIHandle, SCI_BaudRate_9_6_kBaud);
 SCI_enable(MeinSCIHandle);

 PIE_registerPieIntHandler(MeinPIEHandle, PIE_GroupNumber_9, PIE_SubGroupNumber_1, (PIE_IntVec_t)&sciaRxIsr);
 PIE_enableInt(MeinPIEHandle, PIE_GroupNumber_9, PIE_InterruptSource_SCIARX);
 CPU_enableInt(MeinCPUHandle, CPU_IntNumber_9);
 CPU_enableGlobalInts(MeinCPUHandle);  // Enable Global Interrupts
 PIE_clearInt(MeinPIEHandle, PIE_GroupNumber_9);

Functions:

interrupt void sciaRxIsr(void)
{
  // Do something ...
  PIE_clearInt(MeinPIEHandle, PIE_GroupNumber_9);
}

System:

DRV8301-69M-KIT
C2000™ InstaSPIN™ TMS320F28069M MCU
Motorware_1_01_00_14

  • Hi,

    Inside ISR, are you reading the RX buffer? If you not reading RX bufffer then RX buffer will not be empty for next data to receive.

    Regards
    Aditya
  • Hi

    Also you can go through TRM section 13.1.1.8 SCI Port Interrupts for details.

    -Aditya

  • Hi Lukas,

    Just one clarification, so the baud rate set at both ends is 9600 right?

    Regards,
    Gautam
  • Hi,

    thank you for the answers.
    Reading the RX buffer is indeed something that I've forgotten to implement.
    The code line rx_data = SCI_getData(MeinSCIHandle); was initially inside the example code I used but since the compiler couldn't find a definition of this function, I simply commented the line out. I've now had a look at the API documentation and It looks like the function has been replaced by SCI_getDataBlocking and SCI_getDataNonBlocking. I will try out these functions and let you know if the interrupt worked for me.

    With regards to the baud rate, I set it to 9600 inside the code, but inside my serial port reader on the PC, I need to set it to 57600 in order to receive the correct data. If I increase the baud rate inside the code (e.g. 14400) then I'll have to increase the baud rate inside the port reader as well. All the other settings (parity, stop bit...) are the same.

    -Lukas
  • Hi again,

    I've now tried out the SCI_getDataBlocking - function and the interrupt has actually been called more than once (four times).
    However, the 'uint16_t' value that is returned by this function is only one character. If I transmit e.g. the string 'ABCDEF' then the value of this variable will be the ASCII-code of the last character (70 for F). Is there a way I can get the whole string into an array of chars? Is it normal that the interrupt is always triggered four times, no matter the length of the transmitted string?

    Another problem that I still have is that the receive-function only works if I connect the Rx to the Tx pin and transmit via SCI_putDataBlocking. If I connect Rx and Tx to my computer, then I can receive data on my PC (at a different baud rate, as mentioned), but if I enter some text in the console of the serial communication interface and transmit to the controller, then the interrupt won't trigger. Changing the baud rate in the interface doesn't help either.

    Thank you for the help so far.

    -Lukas
  • Hi Lukas,

    First, to address the issue of your incorrect baud rate, the values of the SCI_BaudRate_e enumeration are based on a 15MHz LSPCLK. So if your LSPCLK is running at a different rate, you won't get 9600 as expected. What is your device clock rate? Did you do anything to to set the LSPCLK divider or did you just leave it at the default of /4? The calculation to figure out what you really need to pass to the baudRate parameter is LSPCLK / (SCI Asynchronous Baud * 8) - 1.

    That is the expected behavior of SCI_getDataBlocking(). You need to call it once for every character you receive.

    Thanks,
    Whitney

  • Hi Whitney,

    thank you for your answer. It was actually the system frequency that was responsible for the different baud rates. But the major issue, the problem with transmitting and receiving via the communication interface on the pc, was caused by something I found out just by chance. It turned out that the data has been transmitted via the USB cable for the programmer, which made the communication interface select the wrong COM-port! I work now with a second PC that is used for communication purposes only, which fixed the issue.

    The interrupt is now called once for every character I receive. I implemented a small function that puts every character into an array, which works perfectly!

    Thank you for your help!

    Regards,
    Lukas.