LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Blackfin UART Interrupt/Callback for receiving data

Hi,

I am having trouble structuring a simple program to receive data from the Blackfin UART1.  Data is received over the UART1 every second, so I'm planning on creating an interrupt service routine to read in the data and store it to a global string array .  After reading the following page on Blackfin callbacks,
http://zone.ni.com/devzone/cda/tut/p/id/3244
I believe this is the general way I should approach the problem:

Main VI:
- Static VI reference that references the UART interrupt service routine VI
- Static VI reference connects to BF UART Open block, BF UART Control block, then to the UART interrupt service routine
- Global string array indicator

UART interrupt service routine VI:
- UART Read block with the output buffer appending string to a global string array

This is not working--the global string array does not update.  I have been able to read the data through the UART1 in another VI, but this was not triggered by an interrupt.  Is this the right approach to the problem or does someone have a sample VI that I can look at?

Thanks in advance,
Chris
0 Kudos
Message 1 of 6
(5,972 Views)
Hi Chris,

I would not recommend using the BF UART VIs in an Interrupt VI -- VDK is very strict about what is allowed in ISRs, and in general, it is best to do as liitle as possible in ISRs. Also, the callback will execute when the buffer is full (not necessarily once a second).

Instead, you could do a simple timed loop application that has a period of 1s, and do the UART Read in the timed loop. Or, you could even do something as simple as put the BF UART Read in a while loop that contains a Wait Until Next ms Multiple function to cause the loop to execute once per second. I recommend using the UART echo example as a starting point (attached).
--
Michael P
National Instruments
0 Kudos
Message 2 of 6
(5,949 Views)
Hi Michael,

Thank you for your response.  The reason why I want to use an interrupt is because the data will be composed of a variable amount of bytes (maybe around 20) which will overflow the RBR register (only byte wide) if not recorded fast enough.  This would mean I have to poll much faster than once per second in order to ensure that the beginning of the data is received.  Since data is received only once a second, polling doesn't seem to be the best solution and an interrupt would be a cleaner approach.

I guess I am just unsure of the general structure of how to implement an interrupt VI.  Is my general structure sound?  Is there an example that I can look at?

I have looked at the UART Echo example to get familarized with the open, control, read and write blocks.  I really want to know how to use them in an interrupt service routine.

Thanks in advance,
Chris
0 Kudos
Message 3 of 6
(5,935 Views)
Hi Chris,

This would require a timer interrupt, not a UART interrupt. There are no VIs to create a timer interrupt, which is why I recommended a timed loop. Also, the UART VIs cannot be placed in an Interrupt VI.

The UART driver maintains a buffer, so you shouldn't have to worry about losing a byte if you're receiving data at the rate of 1 byte per second, since you can run a timed loop on the order of milliseconds.
--
Michael P
National Instruments
0 Kudos
Message 4 of 6
(5,930 Views)
Hi every one!
I have a ADSP BF537 EZ kit lite and i would control RF receiver by UART 0. when i program for PC to driver it,  everything is OK. and i have checked TX and RX pulse at pin 2 and pin3 of DB9 connector, these pulses were smooth.
 But when i try driving by ADSP BF537 EZ kit lite using UART 0 with labview embedded for blackfin by using BF UART open VI and BF UART control VI anf BF UART write VI for on/off power only( just send H101) but nothing happened!.
 I have checked TX pin, it has output pulse but these pulse are very distort .
Anybody can help me to solve this problem
thank you very much !
0 Kudos
Message 5 of 6
(5,534 Views)
The above post is answered here
 
 
0 Kudos
Message 6 of 6
(5,507 Views)