Jump to content
Sign in to follow this  
cdenk

Passing Variables With Interrupt?

Recommended Posts

I am converting the provided USART basic to interrupt for the receive, and am having problems with "Static". Have also tried with "Dim c As Byte" "global" (outside functions). Here's the code:

 

'************************************************************************

'* *

'* HARDWARE USART AT 9600 BAUD PROJECT FOR USE WITH BOOST BASIC *

'* *

'* WRITTEN BY : PUNERJOT SINGH MANGAT *

'* COUNTRY : INDIA *

'* CITY : PATIALA *

'* WEB PAGE : www.rackeys.com/punerjot *

'* EMAIL : punerjot@rackeys.com *

'* SOURCEBOOST ID : c58_4311 *

'* RELEASE DATE : May 24, 2006 *

'* REVISED DATE : May 24, 2006 *

'* *

'************************************************************************

 

'

'

'This project file demonstrates the use of the usartbaslib.bas file for making use of

'the hardware USART present inside the PIC

'Note that use of Max232 is must as the signals are inverted

'

'

 

 

Sub main()

Dim c As Byte

 

'dim id_string As String (10) This is the ID of this unit.

'Initialize high interrupt for UART receive

' Disable the watch dog.

wdtcon = 0

' enable interrupts

 

rcon = rcon | (1 << IPEN) 'enable priority interrupts

ipr1 = ipr1 | (1 << RCIP) 'Enable high priority receive interrupt

intcon = intcon | (1 << GIE) 'set global interrupt bit

pir1 = pir1 | (1 << RCIF)

 

call usart_init() 'Initialize software rs232

call usart_tx(65) 'send char A to rs232 terminal

call usart_tx(66) 'send char B to rs232 terminal

call usart_tx(67) 'send char C to rs232 terminal

 

Do while 1

call usart_tx© 'get a char from rs232 terminal and display on lcd

Loop

 

End Sub

 

function Interrupt()

static c As Byte

c = call usart_rx()

pir1 = pir1 | (1 << RCIF)

end function

Share this post


Link to post
Share on other sites

cdenk,

I am converting the provided USART basic to interrupt for the receive, and am having problems with "Static". Have also tried with "Dim c As Byte" "global" (outside functions).  Here's the code:

....

The interrupt function needs to be declared as sub (not function).

dim c As Byte 

sub Interrupt()

c = call usart_rx()
pir1 = pir1 | (1 << RCIF)
end sub

BTW: it looks like the static keyword doesn't work ;)

 

Regards

Dave

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×