Author Topic: UART Interupt  (Read 4654 times)

Offline Kuroro

  • Newbie
  • *
  • Posts: 38
    • View Profile
UART Interupt
« on: June 23, 2008, 04:11:51 PM »
Hello mark

I trie to generate an interupt on a received data but they don't work.

I configure the handler :

Code: [Select]
extern QUEUE_HANDLE fnSetRS485(unsigned char ucDriverMode, uint8 Baud_rate ,uint8 ER )
{
    TTYTABLE tInterfaceParametersRS485;                                       // table for passing information to driver
    tInterfaceParametersRS485.Channel = RS485_UART;                           // set UART channel for serial use
    tInterfaceParametersRS485.ucSpeed = Baud_rate;   // baud rate
    if(ER == RECEPTION)
    {
    tInterfaceParametersRS485.Task_to_wake = TASK_MODBUS;
    }
    tInterfaceParametersRS485.Rx_tx_sizes.RxQueueSize = MODBUS_RX_BUFFER;       // input buffer size
    tInterfaceParametersRS485.Rx_tx_sizes.TxQueueSize = MODBUS_TX_BUFFER;       // output buffer size                        // wake self when messages have been received
    tInterfaceParametersRS485.usConfig = (CHAR_8 | NO_PARITY | ONE_STOP | NO_HANDSHAKE);
    tInterfaceParametersRS485.ucMessageTerminator = '\r';

    if ((SerialPortID = fnOpen( TYPE_TTY, ucDriverMode, &tInterfaceParametersRS485)) != 0) // open or change the channel with defined configurations (initially inactive)
    {
    if(ER == RECEPTION)
    {
    fnDriver( SerialPortID, ( TX_OFF | RX_ON ), 0 );
    }
    if(ER == EMISSION)
    {
    fnDriver( SerialPortID, ( TX_ON | RX_OFF ), 0 );
   
    if(ER == (EMISSION|RECEPTION ))   
    {
    fnDriver( SerialPortID, ( TX_ON | RX_ON ), 0 );
    }
    }
    return SerialPortID;
}

And in the "TASK_MODBUS" i handle the interupt :

Code: [Select]
void fnTacheModbus(TTASKTABLE *ptrTaskTable)
{
QUEUE_HANDLE        PortIDInternal = ptrTaskTable->TaskID;           // queue ID for task input
    unsigned char       ucInputMessage[RX_BUFFER_SIZE];                  // reserve space for receiving messages
   
    while ( fnRead( PortIDInternal, ucInputMessage, HEADER_LENGTH )) // check input queue
    { 
        switch ( ucInputMessage[MSG_SOURCE_TASK] ) // switch depending on message source
        {                 
        case TIMER_EVENT:
            fnRead( PortIDInternal, ucInputMessage, ucInputMessage[MSG_CONTENT_LENGTH]); // read the complete message
            if ((TIME_OUT_FIN_TRAME == ucInputMessage[0]) || (TIME_OUT_NON_REPONSE == ucInputMessage[0]))
            {
            C_Sys_MaitreModbusSci1_Timeout(); // Lancement de la fonction utiliser pour la gestion des 2 TimeOut
            }
        break;   

        case INTERRUPT_EVENT:   
        C_Sys_ModbusSci1Reception(); // Lancement de la fonction de reception a chaque fois qu'un octet et recu
        break;
       
            default :
            break;
        }
    }
}

But the case INTERRUPT_EVENT is not activate when a data is received on the UART.

Did i forgot something ?

Thank's

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3191
    • View Profile
    • uTasker
Re: UART Interupt
« Reply #1 on: June 23, 2008, 09:56:33 PM »
Hi

The UART receiver doesn't send an INTERRUPT_EVENT. It simply wakes the owner task. Therefore the owner task can simply read the UART input queue everytime that it gets worken.

Check out the following too: http://www.utasker.com/forum/index.php?topic=54.msg220#msg220

Regards

Mark

PS. You can simulate the UARTs using the uTasker simulator and also inject a test message via a menu.
PPS. I see that you are waking on a line feed. Check that your configuration (in config.h) is correct to support this.

Offline Kuroro

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: UART Interupt
« Reply #2 on: June 24, 2008, 03:31:35 PM »
Excuse me what do call a "line feed " ?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3191
    • View Profile
    • uTasker
Re: UART Interupt
« Reply #3 on: June 24, 2008, 03:50:34 PM »
Hi

I mean the following:
tInterfaceParametersRS485.ucMessageTerminator = '\r';

(either a line feed or a carrage return - I never know which is which...)

Regards

Mark