• AVR Freaks

Does not write anything to TMR0H

Author
TResell
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2017/09/13 09:11:39
  • Location: 0
  • Status: offline
2017/09/26 08:58:36 (permalink)
0

Does not write anything to TMR0H

My program does not write anything to TMR0H, even though the manual says it will be updated after i write to TMR0L.
What can i do?
See attached picture of program.
 
PIC18F452
MPLAB v8.92
post edited by TResell - 2017/09/26 09:00:15

Attached Image(s)

#1

17 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 18850
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 09:42:43 (permalink)
    +1 (1)
    What are you trying to do?
    You can read then write TMR0H
    For Most compilers 
    TMR0H = TMR0H;
    will work.
    #2
    TResell
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2017/09/13 09:11:39
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 09:47:03 (permalink)
    0
    NKurzman
    What are you trying to do?
    You can read then write TMR0H
    For Most compilers 
    TMR0H = TMR0H;
    will work.


    The program doesn't do anything useful, just proving a point. I'm just trying to write to the two registers (TMR0L and TMR0H). But TMR0H does not change value after i write to it.

    PIC18F452
    MPLAB v8.92
    MPASM v5.51
    #3
    1and0
    Access is Denied
    • Total Posts : 10987
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 10:27:03 (permalink)
    +2 (2)
    It works here. Try restarting your MPLAB and/or computer.
     
    #4
    TResell
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2017/09/13 09:11:39
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 10:28:11 (permalink)
    0
    1and0
    It works here. Try restarting your MPLAB and/or computer.
     


    Do you have a screenshot?

    PIC18F452
    MPLAB v8.92
    MPASM v5.51
    #5
    TResell
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2017/09/13 09:11:39
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 10:33:14 (permalink)
    0
    Thats what i did, i wrote to TMR0H first then i wrote to TMR0L.

    PIC18F452
    MPLAB v8.92
    MPASM v5.51
    #6
    1and0
    Access is Denied
    • Total Posts : 10987
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 10:39:03 (permalink)
    +3 (3)
    TResell
     
    Do you have a screenshot?

    I'm hurt you don't trust me. :(
     
    Anyway, I would but this stupid forum would not let me upload an image. 
    #7
    TResell
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2017/09/13 09:11:39
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 10:41:08 (permalink)
    +1 (1)
    1and0
    TResell
     
    Do you have a screenshot?

    I'm hurt you don't trust me. :(
     
    Anyway, I would but this stupid forum would not let me upload an image. 


    My picture got attached just fine wink: wink
    But i believe you tho Smile: Smile I'll try it soon.

    PIC18F452
    MPLAB v8.92
    MPASM v5.51
    #8
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 10:55:08 (permalink)
    0
    If you include xc.inc then you can use the macros.
     
    movlw 0b00000010 ;does not mean nothing to me or you
    movwf T0CON
     
    Take out the "org" and "goto"
     
    main will appear like any other code, if you want main as in main(), _main

    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.
    #9
    TResell
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2017/09/13 09:11:39
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 11:01:02 (permalink)
    0
    Gort2015
    If you include xc.inc then you can use the macros.

    I don't know what that is. Got any info?
     
    Gort2015 
    movlw 0b00000010 ;does not mean nothing to me or you
    movwf T0CON

    It defines the timer0 to be 16bit, and defines prescale value.
     
    Gort2015
    Take out the "org" and "goto"
     

    I can't take out "org" or it wont run.
     
    Gort2015
    main will appear like any other code, if you want main as in main(), _main

    main is just a label

    PIC18F452
    MPLAB v8.92
    MPASM v5.51
    #10
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3984
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 11:22:15 (permalink)
    0
    I know what what you are trying to do with timer0 but instead of looking at the datasheet and getting the binary bits, .include "xc.inc"
     
    You'll find all the values.
    bset TMR0,#TON ;different chip but you get the idea.
     
    I haven't done any 8bit for a while but it looks something like below.
    Try calling it from C.
     
    GLOBAL _Send
    SIGNAT _Send,4217
    PSECT sendtext,local,class=CODE,delta=2

    _Send:
    BANKSEL(dat)
    movwf dat,f
    BANKSEL (loop8)
    movlw 8
    movwf loop8,f
    loop: etc...




    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.
    #11
    1and0
    Access is Denied
    • Total Posts : 10987
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 11:29:07 (permalink)
    +2 (2)
    Gort2015
    If you include xc.inc then you can use the macros.
     
    movlw 0b00000010 ;does not mean nothing to me or you
    movwf T0CON
     
    Take out the "org" and "goto"
     
    main will appear like any other code, if you want main as in main(), _main

    The <xc.inc> file is for XC8 compiler. OP is using assembly with MPASM.
     
    ORG and GOTO are MPASM directive and instruction, respectively.
     
    The "main" is just a label.
     
    #12
    1and0
    Access is Denied
    • Total Posts : 10987
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 11:30:49 (permalink)
    +3 (3)
    Gort2015
    I know what what you are trying to do with timer0 but instead of looking at the datasheet and getting the binary bits, .include "xc.inc"
     

    All the bit symbols are included in the include file <p18f452.inc> that OP has already included. Again <xc.inc> is for the assembler in the XC8 compiler.
    #13
    1and0
    Access is Denied
    • Total Posts : 10987
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 11:39:52 (permalink)
    +2 (2)
    TResell
     
    My picture got attached just fine wink: 
    But i believe you tho Smile:  I'll try it soon.

    Here 
     
    http://picforum.ric323.co...pic.php?f=32&t=426
    #14
    1and0
    Access is Denied
    • Total Posts : 10987
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 12:08:07 (permalink)
    +4 (4)
    @OP: One of Gort's points is to not use magic numbers; i.e. do this
        bsf     T0CON,TMR0ON

    instead of
        bsf     T0CON,7

     
    #15
    TResell
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2017/09/13 09:11:39
    • Location: 0
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 12:19:39 (permalink)
    +1 (1)
    1and0
    @OP: One of Gort's points is to not use magic numbers; i.e. do this
        bsf     T0CON,TMR0ON

    instead of
        bsf     T0CON,7

     


    I will. It looks a lot better aswell.

    PIC18F452
    MPLAB v8.92
    MPASM v5.51
    #16
    Jim Nickerson
    User 452
    • Total Posts : 6715
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Does not write anything to TMR0H 2017/09/26 14:33:42 (permalink)
    +3 (3)
    In 16 bit timer mode special things happen reading and writing tmr0

    Attached Image(s)

    #17
    Jump to:
    © 2020 APG vNext Commercial Version 4.5