Menu

Want to use TIMER0 as input counter (T0CKI pin 6 on 18F23K20)

Help
Paul Haug
2017-07-17
2017-07-17
  • Paul Haug

    Paul Haug - 2017-07-17

    I cannot get the asm to accept the names from the PIC data sheet.
    Example:
    #config T0CS=1 ;one bit in T0CON
    or
    #config T0CON = 0xA8 ;This would set up timer 0, no prescale, count on positive edge

    So how do I setup timer0 as an input counter.

     

    Last edit: Paul Haug 2017-07-17
  • Anobium

    Anobium - 2017-07-17

    Setup timer0 - see http://gcbasic.sourceforge.net/help/_inittimer0.html is it either OSC or EXT

    To set, note you treat registers and bits similar to variables - you were creating a constant using #define.
    T0CS=1 ;one bit in T0CON T0CON = 0xA8 ;This would set up timer 0, no prescale, count on positive edge

     
  • Paul Haug

    Paul Haug - 2017-07-17

    Ah yes, using #define instead of #config, no more asm error. Will proceed now with with modifying the code for my 'ringtach' ..
    Many thanks.

     

    Last edit: Paul Haug 2017-07-17
  • stan cartwright

    stan cartwright - 2017-07-17

    William Roth posted this for timer 1. Any use if change to timer0?
    '// Configure timer1 as counter on ext pin
    Inittimer1 (EXT, PRE0_1)
    On interrupt Timer1Overflow Call CountOverflows

     
  • Paul Haug

    Paul Haug - 2017-07-17

    Thanks all, I have counter 0 working now

     
  • Anobium

    Anobium - 2017-07-17

    Summary.... use #define to define a constant(s) and treat Registers and Register Bits in a similar was you would use a byte or bit variable.

     

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.