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.

RM48 ISR

Other Parts Discussed in Thread: HALCOGEN

Hi 

I tried to write code with ISR for my RM48HDK 

I used halcogen to configure the code but the code did not enter to sci  notification routine .

anyone have tutorial or demonstration  how to use rm48 /TMS570  ISR with halcogen and ccs5 

thanks a lot 

Yehonatan

  • Hi Yehonatan,

    You will need to create the sciNotification function in the main() function.

    Also you need to run sciInit() in main() to initialize the SCI per your HalCoGEN configuration.

    You can find an example under the Help > Topics > Examples > example_sci_uart_9600.c

    Here is the main function it offers:

    void main(void)
    {

        sciInit();      /* initialize sci/sci-lin    */
                        /* even parity , 2 stop bits */   

        while(1)        /* continious desplay        */
        {
          sciDisplayText(UART,&TEXT1[0],TSIZE1);   /* send text code 1 */
          sciDisplayText(UART,&TEXT2[0],TSIZE2);   /* send text code 2 */
          sciDisplayText(UART,&TEXT3[0],TSIZE3);   /* send text code 3 */ 
          wait(200);
        };
    }

    void sciDisplayText(sciBASE_t *sci, uint8_t *text,uint32_t length)
    {
        while(length--)
        {
            while ((UART->FLR & 0x4) == 4); /* wait until busy */
            sciSendByte(UART,*text++);      /* send out text   */
        };
    }


    void wait(uint32_t time)
    {
        time--;
    }


    /* sci notification (Not used but must be provided) */
    void sciNotification(sciBASE_t *sci, uint32_t flags)
    {
    }

    /* ESM Group notification (Not used but must be provided) */
    void esmGroup1Notification(unsigned channel)
    {
        return;
    }

    /* ESM Group2 notification (Not used but must be provided) */
    void esmGroup2Notification(unsigned channel)
    {
        return;
    }

    Best regards,

    Luc Baudoin

  • Yehonatan,

    Halcogen will generate the code for your SCI initialization as well as the VIM initialization.
    To use interrupt, this has to be specified in your SCI configuration. (Transmit, Receive, Error Interrupts).

    As Luc told you, in your main routine, you have to call the  SciInit routine.

    It is also necessary to enable Interrupt at the CPU level.

    Assuming your SCI is programmed to generate IRQ interrupt, the CPU needs to be IRQ Interrupt Enable.

    This is done by calling the _enable_IRQ();

    Please let us know your result after implementing these modifications.


    Best Regards,


    Jean-Marc


  • Hi 

    I add file which show my code sci2 config and isr config 

    Yehonatan7608.SCI ISR.rar

  • Yehonatan,

    Here is a 5037.SCI_Interrupt.zip test using Interrupt for Transmit.
    The test has been generated with Halcogen, and the main routine as well as the sciNotification modified for the purpose of this test.

    When Halcogen is used to generate driver for SCI it creates a list of function available in the SCI.C file.

    In your main, it is necessary to call the sciInit() to initialize all the parameter (Baudrate, number of data bits, which interrupt to use....)

    Next call in your main is to specify which interrupt will trigger your sciNotofication. This is done by calling sciEnableNotification().
    This function call needs as second parameter the type of interrupt you want to use. The following option are available:

    SCI_FE_INT    - framming error,
    SCI_OE_INT    - overrun error,
    SCI_PE_INT    - parity error,
    SCI_RX_INT    - receive buffer ready,
    SCI_TX_INT    - transmit buffer ready,
    SCI_WAKE_INT  - wakeup,
    SCI_BREAK_INT - break detect

    The SCI_TX_INT is the one used in this example.
    If more than one type of interrupt have to be used, you have to or them as second argument.

    Then it is necessary to enable interrupt at the CPU level by calling _enable_IRQ().

    The VIM configuration is done within Halcogen.

    At that point you can call the sciSend routine.
    This routine can be used in polling or interrupt mode. Again in this example it is interrupt mode.
    Each time a character is send, the sci1HighLevelInterrupt handler is entered (In IRQ Mode)
    The handler will check to SCI->INTVEC0 to see the root cause of this SCI interrupt.
    Based on the result, the sciNotification is called and a parameter is passed. This parameter is the sci interrupt type. (SCI_TX_INT, SCI_RX_INT, SCI_FE_INT....)

    Now in the sciNotification, this parameter is checked and in case of SCI_TX_INT, the sciNotification routine will send another message, this time using the sciSendByte() routine.
    This routine send 1 character at the time and only work in polling mode.

    Please have a try with this code.
    I suggest you to set a break point at the entry point of sci1HighlevelInterrupt() and step the code to see what is happening.

    You can also connect a window terminal to your USB/COMx port. It has to be configured with the following parameters:

    9600 Baud, 8bits, no parity, 1 stop bit, no flow control.

    Please let me know if this will resolve your problem

    Regards,

    Jean-Marc




  • Hi

    The code did not work well there is a problem in the isr function at sci.c it di not enter to the notification function !!

  • HI

    I found intresting bug in sci.c file 

    I ran the demo but somthing did not work well so I check the C file and I saw the following things 

    struct g_sciTransfer
    {
    uint32_t mode;
    uint32_t length;
    uint8_t *data;
    } g_sciTransfer[2];

       g_sciTransfer[1].length = 0;

    .

    .

    .

    case 12:
    /* transmit */
    if (--g_sciTransfer[1].length > 0)
    {
    scilinREG->TD = *g_sciTransfer[0].data++;
    }
    else
    {
    scilinREG->CLRINT = SCI_TX_INT;
    sciNotification(scilinREG, SCI_TX_INT);
    }
    break;

    if I am correct the function should enter to the if statmment because   g_sciTransfer[1].length = 0; and thats what I wants because I want to immpliment my routine 

    but insted of that the if is correct because  (--g_sciTransfer[1].length > 0) 

    I solved the problem by omit the -- sign and I its enter to the function sciNotification but evrey time that I update the hal cogen its did nt work so I reset 

    (--g_sciTransfer[1].length =1;  evrey time in the end of the function and in the init function and its work well 

    I want to know if I am wrong 

    Yehonatan 

  • Yehonata,

    The way the sciSend routine is working is maybe not the way you want.

    This routine is sending all the data from the buffer that is passed as argument.
    For each of the character sent, an interrupt is generated to sent the next one until the full buffer is done.
    Only at that point, the handler will call the sciNotification routine.

    I assume that you want the sciNotification to be called after each character, but this is not the way it is implemented.

    During my debug, I've found a real bug in this routine.

    In the case statement 12 for transmit interrupt we have the following code:

        case 12:
            /* transmit */
            if (--g_sciTransfer[1].length > 0)
            {
                scilinREG->TD = *g_sciTransfer[0].data++;
            }
            else
            {
                scilinREG->CLRINT = SCI_TX_INT;
                sciNotification(scilinREG, SCI_TX_INT);
            }
            break;

    It should be:

        case 12:
            /* transmit */
            if (--g_sciTransfer[1].length > 0)
            {
                scilinREG->TD = *g_sciTransfer[1].data++;
            }
            else
            {
                scilinREG->CLRINT = SCI_TX_INT;
                sciNotification(scilinREG, SCI_TX_INT);
            }
            break;

    I've filed a ticket to the HalCoGen team to fix this problem.

    Please let me know if this explanation are ok for you.

    Regards,

    Jean-Marc

  • Yehonata,

    Did you try the proposed solution to fix your problem?

    Can you update the status of this thread?

    Thanks and Regards,

    Jean-Marc