Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

How to use Getrc5 and monitor port buttons same time?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
jakim

Bascom Member



Joined: 29 Aug 2004
Posts: 8
Location: Estonia

PostPosted: Mon Aug 30, 2004 7:51 pm    Post subject: How to use Getrc5 and monitor port buttons same time? Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5319
Location: Holland

blank.gif
PostPosted: Tue Aug 31, 2004 10:05 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
jakim

Bascom Member



Joined: 29 Aug 2004
Posts: 8
Location: Estonia

PostPosted: Sat Sep 04, 2004 5:21 pm    Post subject: Reply with quote

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
View user's profile
Frankeman

Bascom Member



Joined: 11 Aug 2004
Posts: 945
Location: the Netherlands

netherlands.gif
PostPosted: Sun Sep 05, 2004 7:43 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum