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.

TMS570LS3137: SCI RX interrupt looping

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Hi,

I am currently working on a project around the TMS570LS3137ZWT Hercules Dev Kit. I need to set up the LIN (in SCI mode) module to work as a UART. Normal program flow must be interrupted upon receiving data, to set it in some buffer.

HALCoGen is used to produce code in the following configuration:

- SCI2 driver enabled

- RX INT enabled in SCI/LIN Global

- SCI/LIN Data Format set to fit project, corresponding to setting on PC side

- TX pin set to output direction in SCI/LIN port, both RX and TX pin SCI, pullup mode

- VIM channels 13 and 24 enabled, IRQ (strangely enough, I don't seem to have to call vimInit() for the interrupts to work)

A problem arises when data is received. A single byte is sent from a PC and it is seen and retrieved by the SCI RX interrupt. After that, the interrupt loops, i.e. it is continuously triggered.

Attached is a minimal code snippet that produces this error. "controller_main.h" only contains prototypes of functions ControllerMain() and UponSCIReceive(). ControllerMain() is called in main(), in "sys_main.c" (nothing else happens there). UponSCIReceive() is called in sciNotification() if the flag is SCI_RX_INT (nothing else happens there). No other SCI interrupt than SCI RX are enabled. Interrupts have succesfully been used to implement a HET timer and other things (not shown in the snippet). The looping causes sciSend() or whatever code placed in UponSCIReceive() to be continously executed.

8182.controller_main.c

  • Hello,
    Your code looks fine.
    The receive ready (RXRDY) flag is set when the SCI transfers newly received data from SCIRXSHF to SCIRD. The RXRDY flag therefore indicates that the SCI has new data to be read. RXRDY is cleared by reading SCIRD register.
    I am suspicious about two things:
    - whether PC is not re-sending characters;
    - SCILIN port (SCI2) on TMS570LS3137ZWT Hercules Dev Kit is connected not only to J11, where I am supposing you have connected UART->USB adapter but to U27 (FT2232HL) and used as a UART to USB.
    Is it problem for you to change SCILIN( SCI2) with SCI?

    Best regards,
    Miro
  • Hello Miro,

    Thank you for your reply.

    The PC doesn't seem to be re-sending characters (how could I know if it does without connecting an oscilloscope to the line?). I have tried sending in following situations:
    - From a custom-made program that will be handling the communication when time is right;
    - From RealTerm;
    - From Code Composer Studio embedded console.
    All three produce the same result. I use the SCI from the JTAG/SCI port on J7 i.e. the USB interface.
    The other SCI is supposed to interface another device, so I should get this SCILIN working. If I understodd correctly, the other SCI has TX pin on ball N2 and RX pin on ball W3, so it's not advantageous for me to use these to interface with a PC.

    Best regards,
    Christophe

  • Hello,
    I was thinking that you are not using on-board UART->USB .
    I'll do some tests at my place!

    Best regards,
    Miro
  • Hello,

    I have test with SCI2 with on-board terminal and can not observe the same behavior as you.

    2604.e2e_SCI_INT.zip

    Best regards,

    Miro

  • Hello,

    Indeed, I compiled and uploaded the project in the .zip archive to my board, and got the intended behavior.
    I did a bit more testing, and saw that if I simply handle the interrupt inside the sciNotification() function, everything goes fine.
    But if I call a function from another header in sciNotification(), then I seem to get the interrupt looping behavior.
    I really don't know how this can happen, nor why. I guess that the mistake must be on my side, but I don't find it.

    The solution would be to either handle to interrupt in sciNotification() without external function call, or perhaps use DMA to transfer the data.

    Thank you for your help, let me know if you ever understand where the propblem might be.

    Best regards,
    Christophe
  • Hello Christophe,
    I am closing this thread for now. I'll make more tests and try re-recreate this.

    Best regards,
    Miro