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.

SCI receive problem

Other Parts Discussed in Thread: RM48L952, HALCOGEN

Hello, I am using the RM48L952 Hercules microcontroller.

At the moment I need to program a serial interface between two  microcontrollers. I took the technical reference manual, went to chapter 26 (SCI module) wrote the registers and their addresses, wrote the functions and tested it and it worked.

I can clearly easily exchange bytes between them, but sometimes they miss some data. According to what I've been reading online the SCI module has  and 8 byte internal buffer (I need only 4), which would allow me to send and receive data without any problems (by this I mean that I wouldn't lose bytes just because I didn't poll the bit at the correct time).

Sometimes the data exchange fails, which indicates that there is something wrong with my configuration. So I started reading about the module online and read that it must be put in multi-buffer mode in order to have the 8 bytes, which means that I need to put a 1 in bit 10 of the SCIGCR1 . When I checked the chapter again, to verify this infformation I noticed that the 10th bit was a reserved bit, which had me worried. This led me to verify which chapter I was in and I saw that there are 2 SCI chapters (25 and 26, serial communication interface SCI/LIN module and serial communication interface SCI module).

The SCI/LIN module had the multi-buffer bit but the SCI module didn't. Does this mean that if I'm using the SCI module I'll have to do something about synchronization before starting the data exchange?Will I have to use DMA?

PS: I'm not using HALcogen but I've verified that the generated code is very similar, despite mine having some modifications.

By the way I am using balls W3 and N2 of the microcontroller at address 0xFFF7E500U

  • Pablo,

    You could use interrupts, DMA or polling. The main difference is that each byte will need to be copied as received because without the fifo the SCI is only double-buffered... you have from time of reception of the byte to the time of the reception of the next byte to empty the receive buffer otherwise you will get an overrun.

    -Anthony
  • So ... let me understand.

    I send 4 bytes and the other microcontroller is doing something completely different (both microcontrollers belong to the hercules family). Two seconds later, when it polls the receive bit, it will read the 4 bytes received? This only happensa if it is configured as multi-buffered, and when it is not configured as multi-buffered then it's only double-buffered? OK, I understand this, what I don't understand is:

    why are there two sci chapters? Does it mean that only one of them can be configured as multi-buffer (this is what I understood). How can I know which one I'm using? The one I'm using is in address 0xFFF7E500U and I'm using balls W3 and N2 of the microcontroller. Looking at the datasheet, tables 2-26 and 2-27, this makes me thinks that the SCI module that I'm using is the simple double-buffered one, and if I want to use the multi-buffered one I must use the LIN pins on balls A7 and B7.

    Are my assumptions correct?
  • So:

    -  SCI/LIN and SCI are two different peripherals.

    -  This is why they get two different chapters in the TRM.

       They are pretty 'similar' but still different enough that its' best to

        describe them separately.   If you look closely, you can see that

        basically SCI/LIN evolved from SCI.

    - The 8 byte buffer is only for SCI/LIN

    Pablo Cottens said:
    How can I know which one I'm using? The one I'm using is in address 0xFFF7E500U and I'm using balls W3 and N2 of the microcontroller. Looking at the datasheet, tables 2-26 and 2-27, this makes me thinks that the SCI module that I'm using is the simple double-buffered one, and if I want to use the multi-buffered one I must use the LIN pins on balls A7 and B7.

    Correct.  Also  SCI pins are SCIRX, SCITX.   SCI/LIN pins are named LINRX, LINTX.

    Pablo Cottens said:
    I send 4 bytes and the other microcontroller is doing something completely different (both microcontrollers belong to the hercules family). Two seconds later, when it polls the receive bit, it will read the 4 bytes received? This only happensa if it is configured as multi-buffered, and when it is not configured as multi-buffered then it's only double-buffered?

    You can get a similar behavior with the double buffered mode through the use of the interrupt-driven transfer.

    Yes you will be interrupting the CPU during the transfer but it won't use much of the CPU bandwidth.

    You can look at what the HalCoGen function 'sciReceive' in sci.c does when the interrupt is enabled to see how to make it work interrupt driven.   I would suggest doing this way rather than DMA just because it's simpler and for a few bytes every couple seconds is probably more than enough.

  • Sorry it took me such a long time to answer. I'm in zombie mode today and simply couldn't understand that.