Sign in

username:

password:



Not a member?

Search hc11



Search tips

Subscribe to hc11



Ads

Discussion Groups

Discussion Groups | M68HC11 | IRQ on adapt11

Technical discussions about Freescale Microcontrollers: M68HC11. (Freescale Semiconductor is a Subsidiary of Motorola).

IRQ on adapt11 - fidjouss - Mar 21 14:40:00 2005


Hello

I wrote a small program to test the IRQ interrupt. i am using edge
sensitive. Everytime i turn the switch off, I get something weird. and
my 7 seg led turns off. can anyone please take alook at my program
and see what s wrong.

DIGIT0 EQU $00
PORTC EQU $03
PORTB EQU $04
DDRC EQU $07
PORTD EQU $08
DDRD EQU $09
REGBAS EQU $1000
******************************************************
ORG $FE00
CONFIGURE:
LDX #REGBAS
BSET $39,X $20
LDS #$FF
LDAA #$01
STAA DDRD,X ;PIN1 FOR OUTPUT
LDAA #$00
STAA DDRC,X ;PORTC FOR INPUT
CLR DIGIT0
CLI
****************************************
HERENOW BRA HERENOW
****************************************
READ_PORTC:
LDAA PORTC,X
STAA $00,X
JSR DISPLAY
CLI
RTI

****************************************
DISPLAY:
LDAA $01
STAA PORTD,X ;TURN THE COMMON ANODE OF THE 7SEGMENTS ON
LDAA DIGIT0
STAA PORTB,X ;OUTPUT TO 7SEG LED
RTS
*****************************************
ORG $FFF2
FDB READ_PORTC
ORG $FFFE
FDB CONFIGURE



Re: IRQ on adapt11


(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )


Re: IRQ on adapt11 - Scott Grodevant - Mar 21 14:59:00 2005

Hi all,

The CLI in the interrupt handler isn't needed (and shouldn't be there). RTI restores the interrupt flag state. Be re-enabling interrupts inside the handler, you allow the potential for recursive entries (and might be overflowing your stack).

In general, it's bad form not to save/restore all registers used and to assume any values (like X being set to REGBAS). Further, anytime you have magic numbers in your code, you (or someone else) will hate yourself later. On the other hand, given the context of the program, there is nothing wrong with what you've written.

In DISPLAY, did you mean LDAA #1 to set B1 high?

Good luck,

Scott fidjouss <> wrote:

Hello

I wrote a small program to test the IRQ interrupt. i am using edge
sensitive. Everytime i turn the switch off, I get something weird. and
my 7 seg led turns off. can anyone please take alook at my program
and see what s wrong.

DIGIT0 EQU $00
PORTC EQU $03
PORTB EQU $04
DDRC EQU $07
PORTD EQU $08
DDRD EQU $09
REGBAS EQU $1000
******************************************************
ORG $FE00
CONFIGURE:
LDX #REGBAS
BSET $39,X $20
LDS #$FF
LDAA #$01
STAA DDRD,X ;PIN1 FOR OUTPUT
LDAA #$00
STAA DDRC,X ;PORTC FOR INPUT
CLR DIGIT0
CLI
****************************************
HERENOW BRA HERENOW
****************************************
READ_PORTC:
LDAA PORTC,X
STAA $00,X
JSR DISPLAY
CLI
RTI

****************************************
DISPLAY:
LDAA $01
STAA PORTD,X ;TURN THE COMMON ANODE OF THE 7SEGMENTS ON
LDAA DIGIT0
STAA PORTB,X ;OUTPUT TO 7SEG LED
RTS
*****************************************
ORG $FFF2
FDB READ_PORTC
ORG $FFFE
FDB CONFIGURE
Yahoo! Groups SponsorADVERTISEMENT ---------------------------------
Yahoo! Groups Links

To
---------------------------------




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: IRQ on adapt11 - fidjouss - Mar 21 16:00:00 2005


Thanks for ur response.
Yes I did mean #$01 for pin0 in portd.
My question is when I simulate this program with thrsim11 (with a
switch attached to irq) works fine and gives me correct results.
However, the problem is when I transfer it to the adapt11.
I think there is a problem in reading portc. whatever dip switch
combinations I use, my 7seg led always displays the samething (all
segments are on) when I put irq low.
( I am using a breadboard and when I want to mkae irq low i just plug
attach a cable to the ground since I dont have a threway switch)

Thanks --- In , Scott Grodevant <scott14468@y...> wrote:
> Hi all,
>
> The CLI in the interrupt handler isn't needed (and shouldn't be
there). RTI restores the interrupt flag state. Be re-enabling
interrupts inside the handler, you allow the potential for recursive
entries (and might be overflowing your stack).
>
> In general, it's bad form not to save/restore all registers used and
to assume any values (like X being set to REGBAS). Further, anytime
you have magic numbers in your code, you (or someone else) will hate
yourself later. On the other hand, given the context of the program,
there is nothing wrong with what you've written.
>
> In DISPLAY, did you mean LDAA #1 to set B1 high?
>
> Good luck,
>
> Scott > fidjouss <fidjouss@y...> wrote:
>
> Hello
>
> I wrote a small program to test the IRQ interrupt. i am using edge
> sensitive. Everytime i turn the switch off, I get something weird. and
> my 7 seg led turns off. can anyone please take alook at my program
> and see what s wrong.
>
> DIGIT0 EQU $00
> PORTC EQU $03
> PORTB EQU $04
> DDRC EQU $07
> PORTD EQU $08
> DDRD EQU $09
> REGBAS EQU $1000
> ******************************************************
> ORG $FE00
> CONFIGURE:
> LDX #REGBAS
> BSET $39,X $20
> LDS #$FF
> LDAA #$01
> STAA DDRD,X ;PIN1 FOR OUTPUT
> LDAA #$00
> STAA DDRC,X ;PORTC FOR INPUT
> CLR DIGIT0
> CLI
> ****************************************
> HERENOW BRA HERENOW
> ****************************************
> READ_PORTC:
> LDAA PORTC,X
> STAA $00,X
> JSR DISPLAY
> CLI
> RTI
>
> ****************************************
> DISPLAY:
> LDAA $01
> STAA PORTD,X ;TURN THE COMMON ANODE OF THE 7SEGMENTS ON
> LDAA DIGIT0
> STAA PORTB,X ;OUTPUT TO 7SEG LED
> RTS
> *****************************************
> ORG $FFF2
> FDB READ_PORTC
> ORG $FFFE
> FDB CONFIGURE >
> Yahoo! Groups SponsorADVERTISEMENT > ---------------------------------
> Yahoo! Groups Links
>
> To >
> ---------------------------------




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Re: IRQ on adapt11 - Scott Grodevant - Mar 21 17:16:00 2005

Hi all,

I don't see the value in DIGIT0 being changed, it looks like it is always zero to me. I assume that means all LED segments would light. You read port C and save it in 0,X (very poor form), what memory location is this? Yeah, I don't know either. With my crystal ball in place, didn't you mean to read port C and save it in DIGIT0?

Scott

fidjouss <> wrote:

Thanks for ur response.
Yes I did mean #$01 for pin0 in portd.
My question is when I simulate this program with thrsim11 (with a
switch attached to irq) works fine and gives me correct results.
However, the problem is when I transfer it to the adapt11.
I think there is a problem in reading portc. whatever dip switch
combinations I use, my 7seg led always displays the samething (all
segments are on) when I put irq low.
( I am using a breadboard and when I want to mkae irq low i just plug
attach a cable to the ground since I dont have a threway switch)

Thanks --- In , Scott Grodevant <scott14468@y...> wrote:
> Hi all,
>
> The CLI in the interrupt handler isn't needed (and shouldn't be
there). RTI restores the interrupt flag state. Be re-enabling
interrupts inside the handler, you allow the potential for recursive
entries (and might be overflowing your stack).
>
> In general, it's bad form not to save/restore all registers used and
to assume any values (like X being set to REGBAS). Further, anytime
you have magic numbers in your code, you (or someone else) will hate
yourself later. On the other hand, given the context of the program,
there is nothing wrong with what you've written.
>
> In DISPLAY, did you mean LDAA #1 to set B1 high?
>
> Good luck,
>
> Scott > fidjouss <fidjouss@y...> wrote:
>
> Hello
>
> I wrote a small program to test the IRQ interrupt. i am using edge
> sensitive. Everytime i turn the switch off, I get something weird. and
> my 7 seg led turns off. can anyone please take alook at my program
> and see what s wrong.
>
> DIGIT0 EQU $00
> PORTC EQU $03
> PORTB EQU $04
> DDRC EQU $07
> PORTD EQU $08
> DDRD EQU $09
> REGBAS EQU $1000
> ******************************************************
> ORG $FE00
> CONFIGURE:
> LDX #REGBAS
> BSET $39,X $20
> LDS #$FF
> LDAA #$01
> STAA DDRD,X ;PIN1 FOR OUTPUT
> LDAA #$00
> STAA DDRC,X ;PORTC FOR INPUT
> CLR DIGIT0
> CLI
> ****************************************
> HERENOW BRA HERENOW
> ****************************************
> READ_PORTC:
> LDAA PORTC,X
> STAA $00,X
> JSR DISPLAY
> CLI
> RTI
>
> ****************************************
> DISPLAY:
> LDAA $01
> STAA PORTD,X ;TURN THE COMMON ANODE OF THE 7SEGMENTS ON
> LDAA DIGIT0
> STAA PORTB,X ;OUTPUT TO 7SEG LED
> RTS
> *****************************************
> ORG $FFF2
> FDB READ_PORTC
> ORG $FFFE
> FDB CONFIGURE >
> Yahoo! Groups SponsorADVERTISEMENT > ---------------------------------
> Yahoo! Groups Links
>
> To >
> --------------------------------- Yahoo! Groups SponsorADVERTISEMENT ---------------------------------
Yahoo! Groups Links

To
---------------------------------




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: IRQ on adapt11 - Paul B. Webster VK2BZC - Mar 21 17:29:00 2005

On Mon, 2005-03-21 at 18:40 +0000, fidjouss wrote:

> I wrote a small program to test the IRQ interrupt. i am using edge
> sensitive. Everytime i turn the switch off, I get something weird.

My hackles rise when you use the words "switch" and "IRQ" in the same
sentence.

May I presume that your "switch" is a construction on a "development"
board consisting of a toggle switch or pushbutton whose output is
processed by a debounce circuit, either a flip-flop whose inputs are
controlled by the alternate contacts of the switch, or a schmitt-trigger
gate with a 50 mS (or so) time constant feeding it?

There may be exceptions, but interrupt inputs are *not* (suitable) for
the purpose of detecting switch operation - you use "polling" of a
switch connected to a general-purpose input (and debounce algorithms).

You will note that for the exceptional case of waking from power-down
mode, microprocessors (designed for this purpose) provide a particular
mechanism for activating this function through a nominated input port
(such as for example, mobile phones) which would be connected to the
keypad, rather than IRQ.

--
Cheers,
Paul B.




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )