View previous topic :: View next topic |
Author |
Message |
jakim
Joined: 29 Aug 2004 Posts: 8 Location: Estonia
|
Posted: Mon Aug 30, 2004 7:51 pm Post subject: How to use Getrc5 and monitor port buttons same time? |
|
|
My piece of hardware is intended to be amplifier remote control and digital control system . The problem is how to see the button debounce and getrc5 on the same loop. How to make a jump to the getrc5 routine so that it happens only when data received by Ir receiver.
This doesnt work-
*************
enable interrupts
enable int0
do
begining:
on int0 receiverc5 nosave
'main program'
loop
receiverc5:
getrc5(address and command)
etc.
goto begining
end
********* |
|
Back to top |
|
 |
albertsm
Joined: 09 Apr 2004 Posts: 5736 Location: Holland

|
Posted: Tue Aug 31, 2004 10:05 pm Post subject: |
|
|
Hi,
When you enter an ISR in AVR, the global interrupts are disabled.
This means you need to re-enable them, or better , only the interrupt you want to keep tickining like the timer interrupt that getrc5 is using.
In practice :
receiverc5:
disable int0 ' we dont want to come here again now
enable interrupts ' allow all ints
getrc5 address ,command
enable int0
RETURN ' exit ISR _________________ Mark |
|
Back to top |
|
 |
jakim
Joined: 29 Aug 2004 Posts: 8 Location: Estonia
|
Posted: Sat Sep 04, 2004 5:21 pm Post subject: |
|
|
i tried different loops and still cant get it to work . INT0 works and the ir command is identified but when i want the code to monitor input pins it doesnt work . Can somebody make me simple example which shows on lcd when button is pressed and when rc5 command is decoded |
|
Back to top |
|
 |
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands

|
Posted: Sun Sep 05, 2004 7:43 am Post subject: |
|
|
This is Bascom 8051 code, but with minor changes it will work under Bascom AVR too.
Code: |
Dim New As Bit
Dim Command As Byte , Subaddress As Byte
Reset Tcon.0 'triggered by rising edge
On Int0 Receiverc5
Enable Int0
Enable Interrupts
Do
Debounce P1.0 , 0 , Pr , Sub
If New = 1 Then 'received new code
Disable Int0
Print Command ; " " ; Subaddress
New = 0 'reset new bit
Enable Int0
End If
Loop
Receiverc5: 'interrupt routine
Getrc5(Subaddress,command)
New = 1 'set flag
Return
Pr:
Print "P1.0 was/is low"
Return
|
|
|
Back to top |
|
 |
|