Menu

interrupt on change or hserprint issues

Help
2016-09-08
2016-09-08
  • tony golding

    tony golding - 2016-09-08

    im having some issues with interrupt on change and for the life of me cannot see why its not cooperating.

    i am not using the "on intterupt" option of gcb as this will eventually be going int a pic10f with limited space so for now am using a 16f1825 just to check port change is detected and a counter incremented but so far i am seeing nothing out of the uart to terminal regardless of changing things bit by bit for either the uart settings or the port interrupt settings

    ~~~

    #chip 16f1825, 16
    #config MCLRE = off

    ;USART settings
    #define USART_BAUD_RATE 9600
    #define USART_BL0CKING

    dir PORTA.2 in
    dir PORTC.4 out

    dim count_flag as bit
    dim count_value as Word

    count_flag = 0
    count_value = 0

    IOCAP = b'000000100' ; interrupt on PORTA.2 rising edge
    IOCAF2 = 0 ; clear interrupt flag
    INTCON = b'10001000' ; enable interrupt on change and global interrupts

    ;Main Program starts here
    Do

     if count_flag = 1 Then
    
       INTCON = b'00000000'  ;stop interrupt firing whist sending out uart
    
       HSerPrint count_value
       HserPrintCRLF
    
       count_flag = 0
    
       IOCAF2 = 0            ; clear interrupt flag
       INTCON = b'10001000'  ;re-enable interrupts
    
     end if
    

    Loop

    sub Interrupt

      if IOCAF2 = 1 then
    
      count_value += 1
    
      wait until PORTA.2 = off
    
      count_flag = 1
      IOCAF2 = 0
    
     end if
    

    end sub

    ~~~

    im not sure why this is not working.

    tony

    edit:

    i have just loaded some different code onto this chip that uses uart output and that works fine sending out data, but not when using this code, i have checked the chips uart pin and the specified input pin for my code with multimeter and they show idle high for uart and positive voltage when button input is pressed.

    edit: ammended code above now working

     

    Last edit: tony golding 2016-09-08
  • Anobium

    Anobium - 2016-09-08

    A few general pointers.

    In the compiler we have made changes to enhance the interrupt handler. So, try INTOFF and INTON. Why? The compiler is handling the stack for you and this may be cause of the issue - trying the Gerat Cow BASIC commands.

    You are not clearing IOCAF2 ? In the Interrupt routine. Some of the enhanced chip you must clear the bit.

    Try these - let me know.

     
  • tony golding

    tony golding - 2016-09-08

    darn it, always the simplest thing to overlook, flag now cleared in isr.

    i guess 10 hours of sleep between the last two days is not good lol, thanks evan

    tony

     
  • Chris Roper

    Chris Roper - 2016-09-08

    You managed to get 10 hours sleep in only 2 days, you must be on holiday :)

    Cheers
    Chris

     
    • Anobium

      Anobium - 2016-09-08

      OK. Still make the change to playing the Ints. INTON and INTOFF

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.