Hallo,
Der Bascom Compiler hat ja einen bug, der verhindert beim atmega32 den int0 als zB. rising zu compilen.
folgendes hatte ich gefunden:
Code:
The upshot is:
There IS a compiler error. It states that INTO - INT2 only trigger on low
level.
There is also, I believe, a related error in the simulator that keeps M8,
M16, M32, & M64 from responding to INT0 but allows the other Megas to act
properly.
Workaround? YES, for the compiler... and it's simple.
In the MCUCR (Recognized by Bascom so you can talk to it)
Bits .0 and .1 control INT0
Bits .2 and .3 control INT1
The Bit patterns to set up either Interrupt are:
00 Low Level
01 Any Change* (A NICE Feature not yet addressed by Bascom)
10 Falling Edge
11 Rising Edge
(Each bit has its own name, but these names weren't known to Bascom,)
Simpler code is possible and assembler would be more compact, but the
following code does it:
' To Configure INT0 = FALLING and conserve MCUCR
MCUCR = MCUCR AND &HFC 'Mask off Bits .0 and .1
MCUCR = MCUCR OR &H02 ' "Fallimg" bit pattern
That's all there is. Move two bits to the left for INT1.
DISCLAIMER:
I tested this in the simulator only, not on hardware. It works fine on all
but the mega's listed above. I ASSUME that a simulator error prevents
proper INT action in the simulator and that the workaround will make the
hardware respond properly. I'd appreciate hearing if it does.
P.S.
Its amazing what these data sheets can tell you.
JWC
*On most or all of newer AVRs.
Good thinking ! I must admit that when I think of setting registers and
ports, I automatically fall into ASM mode, forgetting that you can do that
in Bascom as well. Bascom at least hasnt gone the way of the PC world,
where you are totally disconnected from the hardware.
Regards,
Adrian Jansen adrianjansen@internode.on.net
J & K MicroSystems
Microcomputer solutions for industrial control
MCUCR = MCUCR AND &HFC 'Mask off Bits .0 and .1
MCUCR = MCUCR OR &H02
heißt also auf deutsch config int0 = falling... Wie mache ich laut der oben genannten hex-schreibweise aus dem falling ein rising? und aus dem int0 ein int1?
Über schnelle Hilfe wäre ich dankbar...
Gruss
Jan[/code]
Lesezeichen