TMR0 Longer time


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Longer time

    Why not use the prescaler? That will make the timer tick slower.
    Otherwise, just do it the way you're thinking, each time it overflows (indicated by the interrupflag) you increment a variable. When it reaches the desired value you do whatever.
    Just remember to claer the interrupt flag, you have that commented out in the code.

    /Henrik.

  2. #2
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Longer time

    Quote Originally Posted by HenrikOlsson View Post
    Why not use the prescaler? That will make the timer tick slower.
    Otherwise, just do it the way you're thinking, each time it overflows (indicated by the interrupflag) you increment a variable. When it reaches the desired value you do whatever.
    Just remember to claer the interrupt flag, you have that commented out in the code.

    /Henrik.
    Hi H,

    I changed the prescaler bits:

    T0CON.T0PS2 = 0 'Bit2 = 1:2 Prescale value
    T0CON.T0PS1 = 0 'Bit1 = 1:2 Prescale value
    T0CON.T0PS0 = 0 'Bit0 = 1:2 Prescale value

    To:
    T0CON.T0PS2 = 1 'Bit2 = 1:256 Prescale value
    T0CON.T0PS1 = 1 'Bit1 = 1:256 Prescale value
    T0CON.T0PS0 = 1 'Bit0 = 1:256 Prescale value

    But I didn't see any difference.

    You can see the commented out interrupt flag farther down the code.

    Thanks C.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Longer time

    Hi,
    Now that doesn't make sense...
    Which PIC are you using and what clock frequency?

    I don't think I've seen the individual bitnames being predefined like that...which version of PBP are you using?

    /Henrik.

  4. #4
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Longer time

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Now that doesn't make sense...
    Which PIC are you using and what clock frequency?

    I don't think I've seen the individual bitnames being predefined like that...which version of PBP are you using?

    /Henrik.
    Hi H,

    I'm using an 18F2431 PIC in Oshonsoft simulator.

    I just tried the 'time = time + 1' option, and also didn't get proper result, so perhaps I didn't get it correct!

    Can you confirm that if those bits are correct and they are set to 1 which should make 1:265, instead of the previous 1:2. Should it now be slower?

    C.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Longer time

    Hi,
    Yes, TMR0CON = %10001111 should be TMR0 enabled, prescaler assigned to it with ratio 1:256. If I where you I'd try it on real hardware, I'm willing to bet it's a simulator issue...

    You do realise though that this forum is for MeLabs PBP compiler which is not the same as the Oshonsoft compiler, right? They're both BASIC, they're both for PIC but they are not the same.

    /Henrik.

  6. #6
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Longer time

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Yes, TMR0CON = %10001111 should be TMR0 enabled, prescaler assigned to it with ratio 1:256. If I where you I'd try it on real hardware, I'm willing to bet it's a simulator issue...

    You do realise though that this forum is for MeLabs PBP compiler which is not the same as the Oshonsoft compiler, right? They're both BASIC, they're both for PIC but they are not the same.

    /Henrik.
    Hi H,

    I am using the simulator, then putting it on the hardware, as the simulator doesn't actually support what I am doing

    I realise that this is not an Oshonsoft support forum, I have had good replies from this forum, also there isn't much on Oshonsoft.

    Thanks, C.

  7. #7
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Longer time

    Correction. The simulator doesn't support [I]fully[I] what I'm doing.

Similar Threads

  1. Using TMR0 to keep time
    By BraveZero in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd November 2011, 05:25
  2. ArrayRead on longer arrays
    By amgen in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st September 2011, 16:07
  3. Calculate TMR0 reload value at compile time?
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th December 2010, 19:59
  4. PBP is no longer a stranger to Microchip
    By MarioC in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th March 2008, 22:59
  5. code needs much longer then expected
    By mischl in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd March 2006, 02:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts