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.

CCS/TMS570LC4357: SCI tms570 receive via interrupt

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hello,

I am using the tms570 launchpad to communicate using the SCI interface. I am trying to send from sci1 to sci3 on the same board.(sci1 for sending/sci3 for receiving).

I've enabled interrupts for rx on sci3 in the SCI global tab, also enabled in the VIM Channel sci3High/Low interrupts and pinmux for sci3. In the header file _enable_interrupt_() I see  this as being used to enable interrupts for non-OS use( but I also tried with _enable_IRQ_interrupt_() ). On the board I connect the tx of sci1 to the rx of sci3.

When I've debugged, I've noticed that the sciNotification() is never triggered.

I' ll also attach my main source file.

4338.HL_sys_main.c

  • Hi Ciprian,
    Please change "sciEnableNotification(sciREG3,1);" to "sciEnableNotification(sciREG3,SCI_RX_INT);"
    Move sciEnableNotification function before sciSend.
    Let me know if this solve the problem. If this does not solve this problem, please send me you HALCoGen files.
    Do you have oscilloscope to check whether transmit is done?

    Best regards,
    Miro
  • This is the setup:

    pin J5.44(UA1TX) connected to pin J1.3(UA3RX)

    I already did what you said, it won't work. I tried it again even now. I managed to transmit data with sendbyte and receivebyte without using interrupts, but I want to implement interrupts.

    Unfortunately I don't have an oscilloscope, but I checked the sci->td register which is the transmit buffer and the data is shifted correctly through it.

    What's weird is that I did the same thing over an older project and it enabled the interrupts, but even then, the data wasn't transmitted as expected.

    Regards,

    Ciprian.

    .0842.halcogen config.rar

  • Hi Ciprian,
    Please, send *.dil file also. *.dil file is part of HALCoGen project. Without *.dil file I can't load your settings.

    Best regards,
    Miro
  • Sorry, my bad. I was in a hurry.

    8407.sciMS.rar

  • Hi Ciprian,
    In SCI1-->SCI Port, make SCI TX to be output checking DIR checkbox. Do the same in SCI3-->SCI Port tab.

    I don't see other issues. Let me know If this does not help.

    Regards,
    Miro
  • So, by default the pins are inputs? I check the DIR for the tx pin in sci1 port and I also check the rx pin on sci3 port? I need the rx as input on sci3 not output if that DIR checking is making tx pin on sci1 an output.
  • Hello,

    Attached are pictures to what I meant:

    Regards,

    Miro

  • I did that, but I still don't receive data. Anyway, something else that I don't understand is the following:

    I disabled all interrupts and just send byte by byte  because I saw in other instances that somehow I only receive the last byte from sci->td even if I use sciSend/sciReceive not sciSendByte/sciReceiveByte, I don't know why it behaves that way. So, now I use the sciSendByte/sciReceiveByte without interrupts and I can see data when I debug, only if I set the breakpoints as shown below:

    But if I set them in other manner, as shown below:

    It will run in a infinite loop in the sciReceiveByte, waiting for incoming data. I also try to put delay between sending and receiving. Now I am confused, because I don't know if I send/receive any data at all.

    Something is ok, but also wrong in the same time.

    Please can you explain this issue? Also receiving in an interrupt won't work, or the same thing happens and I can't see data that is received at that specific time.

    Regards,

    Ciprian.

  • Hello Ciprian,

    About using SCI receiving in interrupt mode... Please put a breakpoint at interrupt handler (sciHighLevelInterrupt). sciNotification is called inside interrupt handler. If you are entering to interrupt handler, may be sciNotification is not called because if (g_sciTransfer_t[0U].rx_length > 0U) is always false. If this is the case, try attached file. Instead of calling sciReceive prior to send data, you can initialize values manualy.

    6180.HL_sys_main.c

    Best regards,

    Miro

  • What scilinREG is? cause it doesn't exit in any of my headers.

  • Hi Ciprian,
    Sorry, you can delete this raw or you can change it to sciREG1...

    Best regards,
    Miro

  • I manage to send and receive, first of all, if Ithe receiveis present in the main and in the interrupt in the same time, it won't work properly, it works only with the receive in the main and it works properly. I don't really understand why yet, I see that the only change is that FLR register which is manually setted. Also, scilinREG should be sciREG3 cause I am using an interrupt on the receive which is on the sci3. This is how I managed to send and receive properly, I hope this is not only a coincidence. I will further test it and mark this post as a "resolved issue" if nothing weird happens. thank you. I will also post the code from my main, maybe this will help others.
  • Hello Miro,

    So In order to figure this one out I will attach my files, halcogen + HL_sys_main, the following example is working. The main difference was that FLR register which is set up manually in the main. Also, the sciNotification it doesn't work at all, if I use the receive in the sciNotification I only receive the last byte. I don't know why. And if use both, it won't work properly, it will receive the data and afterwards it will replace the first byte in the rx with the last byte from tx, which is basically receiving only the last byte, which I already explained(the receive function should be called only once anyway). I hope that you agree with me on this one. The only thing which I don't understand is that sciNotification function which doesn't work, otherwise all good.

    Regards,

    Ciprian.

    0842.HL_sys_main.rar

    2844.halcogen.rar

  • Hello Ciprian,
    The reason I put sciReceive in main.c is to initialize length... Interrupt handler starts with checking length... sciReceive should be called before sending any data and after first 5 bytes (in your code) were sended  to prepare uart for next bytes (length could be different).

    Best regards,
    Miro

  • But it will mess up the whole thing, just try it. It will actually receive the data if you put the receive function in the main.
  • Hi,
    I have edited my previous post....

    Best regards,
    Miro