UART interrupt mode

Forum related to the FLEX boards

Moderator: paolo.gai

Locked
Alberto_82
Newbie
Posts: 30
Joined: Wed Sep 03, 2008 2:15 pm

UART interrupt mode

Post by Alberto_82 » Fri Oct 24, 2008 9:09 am

Hi,
I have to read some data from UART of my flex board: using the EE_UART_Receive I was able to read all the data correctly. But unfortunatly I have to use interrupt instead of polling. I found a function in eeuart.h header, EE_UART1_SetCallback: is it for reading data with interrupt? If so, can someone explain me how to use it? I can\'t understand how it works...

Thanks to all!
/Alberto

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re:UART interrupt mode

Post by paolo.gai » Sun Oct 26, 2008 8:39 am

I guess you refer to the files into the pic30_serial example...

The general idea of the callback is the following:
- the driver provides all the internal details about handling the serial line.
- but when a data is transmitted or received, only the application knows what to do with that data.
- for that reason, the driver stores in a pointer to function an application callback, which is called upon reception or send of a byte on the serial port. The contect in which the callback is called is an ISR2, so that the application can call RTOS primitives, for example to activate a task or set an event.

but reading the code, It seems they only support Polling; also the callback are not implemented.

If you modify it adding interrupts, please send the result back to nino, so taht we can integrate it into the main build...

Ciao,

PJ

Alberto_82
Newbie
Posts: 30
Joined: Wed Sep 03, 2008 2:15 pm

Re:UART interrupt mode

Post by Alberto_82 » Mon Oct 27, 2008 10:04 am

Ok, I will try to do something.
Thank you!

Ciao,
/Alberto

nino
Newbie
Posts: 15
Joined: Thu Sep 04, 2008 1:14 pm

Re:UART interrupt mode

Post by nino » Fri Nov 07, 2008 3:20 pm

It started as a polling demo, then it was extended. It was not finished yet when the kernel was released, then we had the idea of putting devices support in the board level so the demo was not ended. We hope to have the new support in the next release of the kernel.

desmomito
Newbie
Posts: 27
Joined: Wed Mar 05, 2008 4:03 pm

Re:UART interrupt mode

Post by desmomito » Tue Nov 11, 2008 12:15 am

Hi,
I was reading this post. I\'d like to use UART in interrupt mode too. Could you explain better how to set-up the peripheral in \"Interrupt mode\" ?


Thank you,
Pasquale.

nino
Newbie
Posts: 15
Joined: Thu Sep 04, 2008 1:14 pm

Re:UART interrupt mode

Post by nino » Tue Nov 11, 2008 12:12 pm

The peripheral settings in the described demo are fully working and you can look at them as an example.
It is the I/O management the is still an ongoing part.

desmomito
Newbie
Posts: 27
Joined: Wed Mar 05, 2008 4:03 pm

Re:UART interrupt mode

Post by desmomito » Thu Nov 13, 2008 7:23 pm

Thank you. I\'d like to know if in the Erika code I can use the normal microchip code. For example to initialize a peripheral and for example the classic method to use interrupt which is :

void __attribute__((__interrupt__)) _PERIPHERALInterrupt( void ){
...code
}

I mean if I initialize a peripheral with interrupt it\'s gonna be the above code that will be called or the Erika catch the interrupt and manage it in a different way ?


Thank you in advance,
Pasquale.

chris
Newbie
Posts: 16
Joined: Mon Sep 29, 2008 1:27 pm

Re:UART interrupt mode

Post by chris » Thu Nov 13, 2008 7:32 pm

The answer is yes.
Erika shall not catch any kind of interrupts at all, unless you want erika to do it.
Be aware that with this solution you will not use properly the erika kernel, since the erika interrupt handling has been done to have coherency in the task scheduling mechanism.
To tell the kernel that you want to use an interrupt service routine you should use the ISR2() or ISR1(), look at the erika refman for further details.

The syntax for the same example you mentioned before is:

Code: Select all

ISR2(_PERIPHERALInterrupt) 
{
        /* Interrupt body! */
        code .....
}

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re:UART interrupt mode

Post by paolo.gai » Thu Nov 13, 2008 9:24 pm

Exact. ERIKA does not touch any interrupt unless you want to. All the Microchip code can be used with the Kernel. in that case, the ISR will be called \"ISR Type 1\", whereas \"ISR Type 2\" are the ISR handled by the kernel.

The EE Manuals each contain a table with the list of functions and in which context they they can be called.

PJ

Locked