• AVR Freaks

Hot!16bit begining, PIC24F16KA101, TIMER1 interrupt

Author
Andrius_Vaiceliunas
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2013/11/15 05:03:22
  • Location: 0
  • Status: offline
2018/11/01 06:36:38 (permalink)
0

16bit begining, PIC24F16KA101, TIMER1 interrupt

Good evening. TIMER1 interrupt does not work well. In the initialization, I light the number of hundreds - 4. Then in the first TIMER1 interrupt, tens are lit - the number 6. And it burns endlessly. In work, the number 567 should slowly switch. And so I have two misfortunes:
1) the switching of numbers occurs after 1 sec., when in my calculation TIMER1 interruption should be every 4 seconds (internal RC generator 8 MHz);
2) the second TIMER1 interrupt does not occur.
I will attach the text of the program. Help please.
#1

5 Replies Related Threads

    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3121
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: 16bit begining, PIC24F16KA101, TIMER1 interrupt 2018/11/01 08:01:15 (permalink)
    0
    What is the fcy the chip is running at? (not the internal RC osc.)
    If it is say 40MHz then you would need a 32bit timer since 4 seconds is a lot of time.
     
    fcy = 40,000,000, ps = 256
    4 / (1 / fcy * ps)
    4 / 0.0000064 = 625,000
     
    period = 625,000 - 1
     
    PR High = period >> 16
    PR Low = period (low word only)
     
    Also when using:
    mov   #psvoffset(IND_LENT), W1
    mov #psvpage,tmp
    mov tmp,PSVPAG
     
    You could also use the table instructions and gain access to 24bits rather than 16bits.
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #2
    Andrius_Vaiceliunas
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2013/11/15 05:03:22
    • Location: 0
    • Status: offline
    Re: 16bit begining, PIC24F16KA101, TIMER1 interrupt 2018/11/01 09:06:55 (permalink)
    0
    Do you mean TBLRDH, TBLRDL instructions? Where i can find examples for him?
     
    Or maybe i can use a different code structure for quick "binary -> 7 segment LED" conversion? In 8bit family i use retlw instruction.
    #3
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3121
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: 16bit begining, PIC24F16KA101, TIMER1 interrupt 2018/11/01 09:39:55 (permalink)
    0
    Yes, you can find table instructions in the flash programming specs. section 5.
     
    Do you mean numbers 0 - 9 etc?
    .pushsection segment7data,data
    segment7_data:
    .byte 0x3f,0x6,0x5b,0x4f,0x66,0x6d,0x7c,0x7,0x7f,0x67 ;0-9
    .byte 0x79,0x71,0x39,0x77 ;E,F,C,A
    .popsection

     
    You could also store that in .section .const,psv
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #4
    Andrius_Vaiceliunas
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2013/11/15 05:03:22
    • Location: 0
    • Status: offline
    Re: 16bit begining, PIC24F16KA101, TIMER1 interrupt 2018/11/01 13:45:36 (permalink)
    0
    I need not only the code, but also example with full explanation, i new in 16bit family, i programming just asembler. I write my code whit #psvoffset, but i do not know, how work this offset, step to step. With retlw was easier.
    #5
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3121
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: 16bit begining, PIC24F16KA101, TIMER1 interrupt 2018/11/01 14:45:48 (permalink)
    0
    Use retlw if you find it easier.

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5