View previous topic :: View next topic |
Author |
Message |
jasreb
Joined: 03 Dec 2004 Posts: 41
|
Posted: Thu Oct 18, 2007 10:35 pm Post subject: wakeup on pin change int on ATTiny44 |
|
|
Hi there
I would like to use PCINT9 (portb.1) on ATTiny44 to wake the device from powerdown when the pin goes low level. If I have read the datasheet correctly this should not be a problem.. however..
Bascom 1.11.8.7 does not seem to recognise
config int9 = xxx
or
config pcint9 = xxx
or even
config int1 = xxx
presumably because the ATtiny44.dat file is not up to date to support the multiple pin change interrupts available on the newer devices?
I looked at the ATtiny44 data sheet and pp52-55 seem to imply that portb.1 (PCINT9) can be used to generate a INT1 interrupt if the appropriate bit in the PCMSK1 register is set... is this correct?
if so, my problem is if I can't even get Bascom to config int1 how can I get PCINT9 to work for me? All I want is for PCINT9 to wake the device from powerdown and execute main code loop.
thank you in advance for any advice... :; |
|
Back to top |
|
|
DToolan
Joined: 14 Aug 2004 Posts: 1384 Location: Dallas / Fort Worth, Texas (USA)
|
Posted: Thu Oct 18, 2007 11:14 pm Post subject: |
|
|
Search this forum for PCINT and you'll find lots of information |
|
Back to top |
|
|
jasreb
Joined: 03 Dec 2004 Posts: 41
|
Posted: Thu Oct 18, 2007 11:23 pm Post subject: |
|
|
this is what I have so far..
Code: |
Pcmsk1 = &B00000010 'pin change int PCINT1 on PCINT9 enabled
Gimsk = &B00100000 'enable PCint1
Enable Interrupts
Enable Pcint1 'this may be superfluous?
On Pcint1 Wakeup 'On PCInt1 Wakeup
Powerdown 'goto sleep here
mainloop:
'do stuff here
goto mainloop
End
wakeup: 'PCINT interrupt routine
Disable Pcint1 'ignore further pin changes while awake
Goto Mainloop 'start running main prog
Return
|
|
|
Back to top |
|
|
jasreb
Joined: 03 Dec 2004 Posts: 41
|
Posted: Thu Oct 18, 2007 11:27 pm Post subject: |
|
|
The
Gimsk = &B00100000
line stops the programme running at all...
If it is commented out, program never goes to sleep, it just runs mainloop programme as normal...? |
|
Back to top |
|
|
jasreb
Joined: 03 Dec 2004 Posts: 41
|
Posted: Thu Oct 18, 2007 11:31 pm Post subject: |
|
|
DToolan wrote: | Search this forum for PCINT and you'll find lots of information |
... I did... which is how I got to here... |
|
Back to top |
|
|
DToolan
Joined: 14 Aug 2004 Posts: 1384 Location: Dallas / Fort Worth, Texas (USA)
|
Posted: Fri Oct 19, 2007 12:28 am Post subject: |
|
|
See what this does for you...
Code: | $regfile = "attiny44.dat" 'register file for MEGA128-16
$crystal = 8000000 '8MHz crystal
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
PCMSK1 = &B00000010 'pin change interrupt on PCINT9 enabled
GIMSK = &B00100000 'enable pin change on pin group 8 ~ 11
On PCINT1 Wakeup 'On pin change interrupt Wakeup
Enable Interrupts
Powerdown 'goto sleep here
mainloop: '<-this will be carried out after awakened
'do stuff here
goto mainloop
END
wakeup: 'pin change interrupt routine
PCMSK1 = &B00000000 'disable PCINT9 while awake
Return |
|
|
Back to top |
|
|
jasreb
Joined: 03 Dec 2004 Posts: 41
|
Posted: Sun Oct 21, 2007 12:52 am Post subject: |
|
|
DToolan wrote: | See what this does for you...
Code: | $regfile = "attiny44.dat" 'register file for MEGA128-16
$crystal = 8000000 '8MHz crystal
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
PCMSK1 = &B00000010 'pin change interrupt on PCINT9 enabled
GIMSK = &B00100000 'enable pin change on pin group 8 ~ 11
On PCINT1 Wakeup 'On pin change interrupt Wakeup
Enable Interrupts
Powerdown 'goto sleep here
mainloop: '<-this will be carried out after awakened
'do stuff here
goto mainloop
END
wakeup: 'pin change interrupt routine
PCMSK1 = &B00000000 'disable PCINT9 while awake
Return |
|
thanks for the assistance, I think I have it working at last... will post the working code up soon.. it is a strangely enjoyable exercise discovering bits of Bascom that don't quite do what you think they will, and digging a little deeper to solve it. Of course, having expert (patient) assistance from you guys makes it all a lot more achievable! |
|
Back to top |
|
|
|