Author Topic: Are there UART received interrupts?  (Read 10237 times)

Offline Raffaele

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Are there UART received interrupts?
« on: May 12, 2020, 03:37:05 PM »
Hi,

Is there something like a received UART interrupt in uTasker or how does it work? I mean I define my Serial configuration like this:

Code: [Select]
TTYTABLE tInterfaceParameters; // table for passing information to driver
QUEUE_HANDLE SerialPortID; // UART handle to be obtained during open
tInterfaceParameters.Channel = 0; // set UART channel for serial use
tInterfaceParameters.ucSpeed = SERIAL_BAUD_19200; // baud rate 19�200
tInterfaceParameters.Rx_tx_sizes.RxQueueSize = 256; // input buffer size
tInterfaceParameters.Rx_tx_sizes.TxQueueSize = 512; // output buffer size
tInterfaceParameters.Task_to_wake = TASK_MY_UART; // wake task on rx
#ifdef SUPPORT_FLOW_HIGH_LOW
tInterfaceParameters.ucFlowHighWater = 80; // set the flow control high in %
tInterfaceParameters.ucFlowLowWater  = 20; // set the flow control low in %
#endif
tInterfaceParameters.Config = (CHAR_8 + NO_PARITY + ONE_STOP + USE_XON_OFF + CHAR_MODE);
if ((SerialPortID = fnOpen( TYPE_TTY, FOR_I_O, &tInterfaceParameters)) != 0) {
// open the channel with defined configurations (initially inactive)
fnDriver(SerialPortID, ( TX_ON | RX_ON ), 0); // enable rx and tx
}
DebugHandle = SerialPortID;

now, when I receive a new message my task should be waken up, but how does it actually happen? Is there an interrupt that makes uTasker execute my task or does it happen just because UART senses something? I'm trying to get to that point because I can transmit over UART but my task is not executed upon reception

Thank you
« Last Edit: May 12, 2020, 03:38:46 PM by Raffaele »

Offline Raffaele

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Are there UART received interrupts?
« Reply #1 on: May 12, 2020, 04:56:19 PM »
I found part of the problem I think.
Functions such as fnMsgs(SerialPortID) or fnWrite(SerialPortID, (unsigned char *)ucRx, ucLength); get stuck, but I'm not sure how to solve this problem

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Are there UART received interrupts?
« Reply #2 on: May 12, 2020, 05:00:44 PM »
Hi

Both Tx and Rx UARTs operate with interrupts.

If fnMsgs() and fnWrite() fail it is probably due to the fact that the handle SerialPortID is invalid (or uninitialised). A value of 0 will fail.

This can happen when you open an interface and it doesn't have enough memory on the HEAP to be able to allocate its Rx/Tx queues.

Regards

Mark

Offline Raffaele

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Are there UART received interrupts?
« Reply #3 on: May 12, 2020, 05:16:58 PM »
I fixed the fnMsg(SerialPort) and does not get stuck, in fact I get SerialPortID >0. But for some reason I still don't get the UART interrupt. When I configure my serial interface table, where in the code is it associated to the UART Rx interrrupt?