View previous topic :: View next topic |
Author |
Message |
RON1406
Joined: 17 Feb 2005 Posts: 15 Location: Opwijk
|
Posted: Thu Apr 13, 2006 9:31 am Post subject: Timer0 for ATtiny 13 |
|
|
Hello,
Did someone among you use timer0 in normal overflow operation on a tiny13? I used this little program to see if the interrupt was done but it doesn't seem to work. Am I overlooking something?
$regfile = "ATtiny13.DAT"
$crystal = 9600000
Config Portb.3 = Output
Config Timer0 = Timer , Prescale = 1024
Led Alias Portb.3
Reset Led
Timer0 = 100
On Timer0 Tijd
Enable Timer0
Enable Interrupts
Start:
Goto Start
Tijd:
Stop Timer0
Set Led
Goto Tijd
Return
End
Many thanks already,
Ron, |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Thu Apr 13, 2006 9:51 am Post subject: |
|
|
Hi,
Why are you jumping back to tijd in you ISR?.
The ISR will only be called once, then the code will sit in a loop setting the LED and stopping the timer.
To see if the timer is working try this:-
Code: |
$regfile = "ATtiny13.DAT"
$crystal = 9600000
Config Portb.3 = Output
Config Timer0 = Timer , Prescale = 1024
Led Alias Portb.3
Reset Led
Timer0 = 100
On Timer0 Tijd
Enable Timer0
Enable Interrupts
Start: 'do nothing loop
nop
Goto Start 'forever
End
tijd:
Toggle LED 'Invert LED output
TIMER0 = 100 'Reload timer value (otherwise it'll start again from 0)
return
|
Hope this helps
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
RON1406
Joined: 17 Feb 2005 Posts: 15 Location: Opwijk
|
Posted: Thu Apr 13, 2006 10:31 am Post subject: |
|
|
This little program was just written to let activate the interrrupt and then to indicate with a led and then stop the controller in a way. So that I can see that the controller had done the interrupt.
I was also forgotten to mention that I work here with a registered
Bascom 1.11.7.9 The tiny13 is already supprted here.
Many thanks already,
Ron, |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Thu Apr 13, 2006 11:21 am Post subject: |
|
|
Hi,
But does my code work? A flashing LED is easier to see than one that might light of 0.1sec when the CPU is powered up.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
RON1406
Joined: 17 Feb 2005 Posts: 15 Location: Opwijk
|
Posted: Thu Apr 13, 2006 12:00 pm Post subject: |
|
|
No , your code doesn't work either. I even placed a logic probe with memory on the led.
And if I place for example in between the endless loop of start:
start:
toggle led
waitms 250
goto start
Then the led works. So it means that actually the µcontroller is working fine , only the interrupt isn't activated. And I really have no idea what I'm doing wrong ...
Many thanks already,
Ron, |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Thu Apr 13, 2006 4:43 pm Post subject: |
|
|
Hi,
Try using the overflow interrupt:-
Something like:-
On Ovf0 tijd
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
RON1406
Joined: 17 Feb 2005 Posts: 15 Location: Opwijk
|
Posted: Fri Apr 14, 2006 7:38 am Post subject: |
|
|
Hello Ian,
No , the Ovf0 doesn't seems to work either. Could it be that I need a higher version of Bascom? I have a registered 1.11.7.9 and the tiny13 is supported in the list , but maybe there were still some errors with? I tried to do an upgrade but this auto update doesn't seem to work either...
Many thanks already,
Ron, |
|
Back to top |
|
|
RON1406
Joined: 17 Feb 2005 Posts: 15 Location: Opwijk
|
Posted: Fri Apr 14, 2006 2:11 pm Post subject: |
|
|
Ian , I finally got it to work now. Looks like Bascom isn't working properly there. I added :
Timer0 = 100
On Ovf0 Tijd
Timsk = 2
Tccr0a = 0
Tccr0b = 5
Enable Interrupts
And now the interrupt is done. This is in a way the manual way to program this chip. But now it works .... anyway , many thanks for your help.
Ron, |
|
Back to top |
|
|
rickinphx
Joined: 09 Apr 2006 Posts: 1
|
Posted: Tue Apr 18, 2006 12:01 am Post subject: |
|
|
I played with Timer0 for hours with the mega8515 trying to do the same thing. One problem was that the enable interrupt flag in the SREG reg. (bit 7) got reset after the first time the interrupt occurred and the interrupt didn't work anymore. Had to "enable interupts" in the service routine every time.
Rick in Phx. |
|
Back to top |
|
|
|