View previous topic :: View next topic |
Author |
Message |
2New
Joined: 11 Feb 2007 Posts: 25
|
Posted: Mon Apr 18, 2011 4:55 pm Post subject: Attiny2313/ PortD |
|
|
Hi,
I'm faced with a nasty little problem. As soon as the programme enters Portd= &B01000000 it jumps permanently between this line and the headline.
Who will give me support? |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Mon Apr 18, 2011 6:28 pm Post subject: |
|
|
Hi
Portd = &B01000000
This will set your PULLUP on INT0 to 0 !!! (portd.2)
try set it high like this
Portd = &B01000100
About INT0 :
Quote: | LOW LEVEL to generate an interrupt while the pin is held low. Holding the pin low will generate an interrupt over and over again.
FALLING to generate an interrupt on the falling edge.
RISING to generate an interrupt on the rising edge.
CHANGE to generate an interrupt on the change of the edge. Not all microprocessors support CHANGE.
|
Do you realy need to generate an interrupt over and over again ?
did you try config INT0 like this ?
Config Int0 = Falling
and you dont need a Integer if you just need to count to 3 ,
Integer is two bytes !!
try use byte for Gzs 1/2/3
And you can move END to after DO LOOP _________________ / Kim
Last edited by kimmi on Mon Apr 18, 2011 6:59 pm; edited 1 time in total |
|
Back to top |
|
|
2New
Joined: 11 Feb 2007 Posts: 25
|
Posted: Mon Apr 18, 2011 6:59 pm Post subject: |
|
|
kimmi wrote: | Hi
About INT0 :
Quote: | LOW LEVEL to generate an interrupt while the pin is held low. Holding the pin low will generate an interrupt over and over again.
FALLING to generate an interrupt on the falling edge.
RISING to generate an interrupt on the rising edge.
CHANGE to generate an interrupt on the change of the edge. Not all microprocessors support CHANGE.
|
Do you realy need to generate an interrupt over and over again ?
did you try config INT0 like this ?
Config Int0 = Falling
and you dont need a Integer if you just need to count to 3 ,
Integer is two bytes !!
try use byte for Gzs 1/2/3
And you can move END to after DO LOOP |
Hi Kimmi,
I've condensed the full programme down to the problem. In reality I need Integer. For all applications I'm using Int0 = low level but the other possibilities didn’t solve the difficulty neither to put “end” behind loop-
Thanks so far. |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Mon Apr 18, 2011 7:00 pm Post subject: |
|
|
The problem is your PULLUP on INT0 (Portd.2 = 1)
Portd = &B01000000
This will Reset your PULLUP on INT0 !!! (portd.2=0)
try set it high like this :
Portd = &B01000100 _________________ / Kim |
|
Back to top |
|
|
2New
Joined: 11 Feb 2007 Posts: 25
|
Posted: Mon Apr 18, 2011 7:07 pm Post subject: |
|
|
kimmi wrote: | Hi
Portd = &B01000000
This will set your PULLUP on INT0 to 0 !!! (portd.2)
Ddrd = &B01110000 and Portd.2 = 1 means Portd2 is Input and set high. Nevertheless I tried it without any success.
try set it high like this
Portd = &B01000100
About INT0 :
Quote: | LOW LEVEL to generate an interrupt while the pin is held low. Holding the pin low will generate an interrupt over and over again.
FALLING to generate an interrupt on the falling edge.
RISING to generate an interrupt on the rising edge.
CHANGE to generate an interrupt on the change of the edge. Not all microprocessors support CHANGE.
|
Do you realy need to generate an interrupt over and over again ?
did you try config INT0 like this ?
Config Int0 = Falling
and you dont need a Integer if you just need to count to 3 ,
Integer is two bytes !!
try use byte for Gzs 1/2/3
And you can move END to after DO LOOP |
|
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Mon Apr 18, 2011 7:10 pm Post subject: |
|
|
Ddrb = &B01011111
Ddrd = &B01110000
Portd.2 = 1 this set INT0 HIGH
but when you set Portd.6 high you RESET INT0 pullup (Portd = &B01000000)
Try:
Code: | Ontick03:
Portd = &B01000100 ' PORTD.6 =1 AND INT0 HIGH (Portd.2 = 1)
Waitms T
Gzs3 = 0
Return |
_________________ / Kim |
|
Back to top |
|
|
2New
Joined: 11 Feb 2007 Posts: 25
|
Posted: Mon Apr 18, 2011 7:18 pm Post subject: |
|
|
kimmi wrote: | Ddrb = &B01011111
Ddrd = &B01110000
Portd.2 = 1 this set INT0 HIGH
but when you set Portd.6 high you RESET INT0 pullup
Try:
Code: | Ontick03:
Portd = &B01000100 ' PORTD.6 =1 AND INT0 HIGH (Portd.2 = 1)
Waitms T
Gzs3 = 0
Return |
|
Quote: |
Kimmi,
Stupid failure, you are right now it works perfect, Thank you. |
|
|
Back to top |
|
|
|