Menu

No prescaler mode with 18F452

Help
gcha44
2010-11-28
2013-05-30
  • gcha44

    gcha44 - 2010-11-28

    I want to use 18F452 with Timer0 , Timer0 interrupt , and external transition on RA4/TOCKI  without prescaler .

    But in GCBasic ,  with "initTimer0"  it's not possible because minimal prescale selection is "initTimer0 ext,PS_2"  !!
    Can I write:  "TOCON.3=1  "  to correct that ?
    In GCBasic Help ,it's written that  Timer0 overflow after 256 impulses . But with 18F452 I'll want to use 16 bits mode . Can I also write  "T0CON.6=0"  and read the timer0 value in TMR0H and TMROL ? Will Timer0 overflow after 65535 ?
    Thanks
    GC

     
  • kent_twt4

    kent_twt4 - 2010-11-28

    At first glance it looks like timer.h library doesn't handle 16 bit mode for TMR0 either, so setting up TMR0 manually looks like the way to go.

    Should be able to write and read to TMR0H and TMR0L registers, although reading TMR0L first is a good idea.  Now do you reverse that order when writing? I am not clear.

    I like using the whole register on initialization T0CON = b'00101000', then toggling the bit names when appropriate like
    TMR0ON = 1.

    Yes, the TMR0IF flag should interrupt on the 16 bit overflow value in TMR00L and TMR0H.

     
  • gcha44

    gcha44 - 2010-11-28

    Thanks Kent . Your answer is very clear and I discover  that I had sometimes erratic results because  I didn't always read first TMR0L or TMR1L !
    Thanks again
    GC

     

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.