Menu

Timer1 problems on 16lf18326

Help
2016-11-15
2016-11-16
  • David Stephenson

    Finally got the HI2C working on this chip (I think it was a #config problem). Now I am having trouble getting the timer1 module to cause an interrupt on overflow (during sleep).
    This is what I have (it works fine on a 16F1705 - which as far as I can see has the same registers associated with timer1 and interrupts)

    #chip 16LF18326,4
    #config RSTOSC=hfint1, MCLRE=Off, WDTE=off, boren=off
    
    dir porta.4 in 'timer1
    dir porta.5 in 'timer1
    TMR1H=b'1000000'
    TMR1L=b'0000000'
    pir1.0=0
    t1con=b'10001101' 'timer1 1:1
    intcon.7=1
    pie1.0=1
    t1gcon.7=0
    do
    '********program here
    sleep
    nop
    pir1.0=0
    loop
    
     
    • Anobium

      Anobium - 2016-11-15

      Look in your install for this demo. 15 Rotate the LEDs using the Timer Overflow Event.gcb This is in the Vendor Demos\GCB Board folders.

      But, you have not set T1GPPS = 0x04. Is this required?

      And, are you saying when you select 4mhz the incorrect oscillator is selected?

       
  • David Stephenson

    I have a clock crystal (32kHz) on the socsi/sosco pins as a secondary oscillator to provide interrupts every second (accurately). I am using the internal oscillator at 4MHz as the cpu oscillator.
    As far as I can see the secondary oscillator pins cannot be reconfigured by the PPS (the T1GPPS is a gate for the oscillator which I have disabled).

    I cannot find the vendor demos\GCB board folders.

     
  • Anobium

    Anobium - 2016-11-16

    I did not show the complete folder structure - it was more of a pointer for you. :-)

    ..\GCB@Syn\GreatCowBasic\Demos\Vendor Boards\Great Cow Basic Demo Board\16f18326 ChipRange Demonstrations

     
  • David Stephenson

    So I am currently in https://sourceforge.net/p/gcbasic/discussion/ how do I find that directory?

     
    • Anobium

      Anobium - 2016-11-16

      This is in your local computer installation. You have 500+ demos installed.

       
  • Anobium

    Anobium - 2016-11-16

    Try this. I am wonder if we are setting, in the lowlevel code, something that you are also setting.

    #chip 16LF18326,4
    #config RSTOSC=hfint1, MCLRE=Off, WDTE=off, boren=off
    #option Explicit
    
    dir porta.4 in 'timer1
    dir porta.5 in 'timer1
    SetTimer 1, 0x4000
    
    
    StartTimer 1
    TMR1CS1=1
    TMR1CS1=0
    T1SOSC = 1
    T1SYNC = 1
    
    
    TMR1IF = 0
    TMR1IE =1
    IntOn
    
      do
      '********program here
        sleep
        nop
        TMR1IF = 0
      loop
    
     
  • David Stephenson

    Well I'm glad I've finally found the demos!
    No those alterations still do not work. I'm pretty sure everything is correct and it works on a 16F1705 which has very similar settings for the T1 oscillator.
    I'm beginning to wonder if the oscillator module in this chip is a bit more fussy and the clock crystal is not oscillating - I will investigate.

     
  • David Stephenson

    No it is not even oscillating. With a 16F1705 in its place I see the 32kHz oscillations on pin RA5.

     
    • Anobium

      Anobium - 2016-11-16

      Study these...these are the demo configs.

      #Config WRT_OFF, CPD_ON, MCLRE_ON, FEXTOSC_OFF, CLKOUTEN_OFF 'These configs = User non-votatile protection off (WRT), Data non-votatile protection off (CPD), MCLR pin function enablesd, External oscillator not enabled and clockout function is disables ( enable portc.5 to I/O port).

      So, FEXTOSC_OFF, CLKOUTEN_OFF is the key.

       
  • David Stephenson

    Thanks again. That has done the trick. These newer types certainly have challenging #config settings.
    I guess I also need WRT_OFF to write to memory.

     
    • Anobium

      Anobium - 2016-11-16

      Don't be guessing..... LOL!!!

       

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.