Doubt with interrupts with MC9s08sh8

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Doubt with interrupts with MC9s08sh8

696 Views
glaa91
Contributor I

Hi, i'm trying to make a program that when i put VCC on one pin of the PortA, the program jump to an Interrupt and turns on a Led on Port B.

The problem is that i can't configure the interrups, and i can't find my error, can anyone help me?? Thanks

it's a simply test program, here it's:

 

 

; Include derivative-specific definitions

            INCLUDE 'derivative.inc'

; export symbols

;

            XDEF _Startup

            ABSENTRY _Startup

 

; variable/data section

;

            ORG    RAMStart         ; Insert your data definition here

            ORG    ROMStart

 

_Startup:

       LDA SOPT1 ;Deshabilita COP

       AND #%00111111

       STA SOPT1

       LDHX #RAMEnd+1 ; initialize the stack pointer

       TXS

 

       MOV #%00000001,PTBDD

       MOV #%00000000,PTCDD

 

       MOV #%00000000,PTAES ;SLEW RATE

       MOV #%00000000,PTADD ;IN/OUT

       MOV #%00111111,PTAPE ;PULL-UP/PULL-DOWN

       MOV #%00001111,PTASC ;INTERRUP STATUS AND CONTROL

       MOV #%00001111,PTAPS ;HABILITAR/DES INTERRUPCIONES

       ;MOV #%00001111,PTAES ;

 

       CLI

 

 

INICIO:

       BCLR 0,PTBD

ini

       JMP ini

 

;**************************************************************

;* spurious - Spurious Interrupt Service Routine.             *

;*             (unwanted interrupt)                           *

;**************************************************************

interrup:

            NOP   

            SEI

            BSET 0,PTBD

            CLI   

            RTI   

 

 

spurious: ; placed here so that security value

            NOP ; does not change all the time.

       RTI   

 

 

;**************************************************************

;*                 Interrupt Vectors                          *

;**************************************************************

  ORG $FFD6

  DC.W interrup

 

 

  ORG $FFFA

 

 

  DC.W  spurious ;

  DC.W  spurious ; SWI

  DC.W  _Startup ; Reset

Labels (1)
0 Kudos
2 Replies

433 Views
bigmac
Specialist III

Hello,

There are two problems that I can see -

  1. The interrupt edge select register PTAES would seem to have the incorrect setting for what you require.  This is not the slew rate register, as your comment indicates!  Your settings will give falling edge interrupt operation, with pullups enabled, consistent with a grounded switch contact.
    MOV #%00000000,PTAES ;SLEW RATE
  2. The interrupt will need to be acknowledged within your ISR code, to clear the interrupt flag.  Otherwise repeated interrupts will occur.  Additionally, unless you have a specific need for combined edge and level sensitivity for the interrupt, I might suggest that you set for edge sensitive interrupts only.  Level sensitive interrupts will potentially cause multiple interrupts while the input level remains active.

interrup:

            NOP             ; Unnecessary instruction

            SEI             ; Unnecessary instruction

            MOV  #%00000110 ; Acknowledge interrupt

            BSET 0,PTBD

            CLI             ; Unnecessary instruction

            RTI   

Regards,

Mac

433 Views
glaa91
Contributor I

Hi, thanks you very much for the answer, but i'm still having problems... I can not make that the program works, it is never jumping to the interrupt, can you give me a little more help?

Here is the modified code:

_Startup:

            LDA SOPT1 ;Deshabilita COP

            AND #%00111111

            STA SOPT1

            LDHX #RAMEnd+1 ; initialize the stack pointer

            TXS    

       MOV #%00000001,PTBDD    

       MOV #%00000000,PTCDD    

       ;MOV #%00001111,PTAES      ;INTERRUP EDGE    

       ;MOV #%00011111,PTASE      ;SLEW RATE    

       MOV #%00000000,PTADD      ;IN/OUT    

       MOV #%00001111,PTAPE      ;PULL-UP/PULL-DOWN    

       MOV #%00000110,PTASC      ;INTERRUP STATUS AND CONTROL    

       MOV #%00001111,PTAPS      ; Enable/disable interrups   

       CLI    

INICIO:

       BCLR 0,PTBD    

ini

       JMP ini    

;**************************************************************

;* spurious - Spurious Interrupt Service Routine.             *

;*             (unwanted interrupt)                           *

;**************************************************************

interrup:

       ;NOP    

       ;SEI    

       MOV  #%00000110,PTASC ; Acknowledge interrupt    

       BSET 0,PTBD

       ;CLI    

       ;RTI    

spurious: ; placed here so that security value

  NOP ; does not change all the time.

  RTI

;**************************************************************

;*                 Interrupt Vectors                          *

;**************************************************************

  ORG $FFD6

  DC.W interrup

  ORG $FFFA

  DC.W  spurious ;

  DC.W  spurious ; SWI

  DC.W  _Startup ; Reset

Thanks,

Gaston.

0 Kudos