Menu

SOSC On 18F26K80 won't run

mmotte
2023-12-18
2023-12-19
  • mmotte

    mmotte - 2023-12-18

    I am using the 18F26K80 because it has a 12bit A/D and i have a tube full of them.
    I have been using the internal clock to run the RTC for data logging but it runs a little off.

    My hardware runs with a 16F886 plugged in on the external osc on T1 just fine.
    But when I try to use the 18F26K80 it bawks! Same program except for chip statement and read AD12 instead of readAD10.

    12:9:37, 16:11:43, 1023,1023
    12:9:39, 16:11:45, 1023,1023
    12:9:42, 16:11:48, 1023,1023    '16F886
    12:9:44, 16:11:50, 1023,1023
    12:9:46, 16:11:52, 1023,1023
    12:9:48, 16:11:54, 1023,1023
    12:9:50, 16:11:56, 1023,1023
    þadcon1= 4812:2:0, 16:4:5, 31,27
    12:2:0, 16:4:5, 128,112         '18F26K80
    12:2:0, 16:4:5, 258,226
    12:2:0, 16:4:5, 412,360
    12:2:0, 16:4:5, 581,509
    12:2:0, 16:4:5, 731,641
    12:2:0, 16:4:5, 824,722
    12:2:0, 16:4:5, 887,780
    

    I have searched the Forum and my program is just like the programs in the forum.

    I don't know what I am missing?

    I have read the data sheet.
    I have tried configuring directly.

    Please any ideas?

    Mike w9ys

     
  • mmotte

    mmotte - 2023-12-18

    I know you usually ask for the .asm file.

    here it is

     
  • Anobium

    Anobium - 2023-12-19

    Interesting.

    What is the value of T1CON after InitTimer1 sosc, 0 ?


    And, I have just learnt this!

    Dim enter as string
    enter = 13, 10 
    

    So, clever!!

     
  • mmotte

    mmotte - 2023-12-19

    Hi Anobium,

    Been trying to understand the 18F26K80 pdf and it talked about waiting for the sosc to start.

     'Interrupt Handlers
      InitTimer1 sosc, 0
      HSerprint "after init T1CON = 0x"
      HSerprint hex(T1CON)
      HSerprintCRLF
    
      HSerprint "OSCCON2 = 0x"
      HSerprint hex(OSCCON2)
      HSerprintCRLF
      StopTimer 1
      settimer 1,0x8000       ' 16bit load bit is set to allow
      'SOSCSEL1 =1
      'SOSCSEL0 =1
      wait 50 us
      On Interrupt Timer1Overflow Call RTC
    
      'T1CON = 0x8B     'Enable SOSCEN external 32k osc
      StartTimer 1
    

    But the wait did not help.

    12:2:0, 16:4:5, 660,557
    12:2:0, 16:4:5, 880,743
    12:2:0, 16:4:5, 1098,928
    after init T1CON = 0x88
    OSCCON2 = 0x12
    after init T1CON = 0x88
    OSCCON2 = 0x12
    after init T1CON = 0x88
    OSCCON2 = 0x12
    after init T1CON = 0x88
    OSCCON2 = 0x12
    after starttimer1 T1CON = 0x89
    OSCCON2 = 0x12
    12:2:0, 16:4:5, 110,92
    12:2:0, 16:4:5, 329,277
    

    Looks right

    Mike

     
  • Anobium

    Anobium - 2023-12-19

    T1CON should be 0x81. Set T1CON = 0x81after the StartTimer 1

    This should work.

     
  • mmotte

    mmotte - 2023-12-19

    Didn't work.

    12:2:0, 16:4:5, 1105,926
    12:2:0, 16:4:5, 1104,927
    after init T1CON = 0x88
    OSCCON2 = 0x12
    after init T1CON = 0x88
    OSCCON2 = 0x12
    after starttimer1 T1CON = 0x81
    OSCCON2 = 0x12
    12:2:0, 16:4:5, 166,144
    12:2:0, 16:4:5, 348,300
    

    Actually starttimer1 give 0x89 which is correct because bit 3 of T1CON is SOSCEN should be 1


    I took the HSerPrint statements out because they might be interfering with startup and gave it a 500 us wait before "starttimer1"

    12:2:0, 16:4:5, 1085,919
    after starttimer1 T1CON = 0x89
    OSCCON2 = 0x12
    12:2:0, 16:4:5, 219,183
    
     'Interrupt Handlers
      InitTimer1 sosc, 0
      'HSerprint "after init T1CON = 0x"
      'HSerprint hex(T1CON)
      'HSerprintCRLF
    
      'HSerprint "OSCCON2 = 0x"
      'HSerprint hex(OSCCON2)
      'HSerprintCRLF
      'StopTimer 1
      settimer 1,0x8000       ' 16bit load bit is set to allow
      'SOSCSEL1 =1
      'SOSCSEL0 =1
      wait 500 us
      On Interrupt Timer1Overflow Call RTC
    
      'T1CON = 0x8B     'Enable SOSCEN external 32k osc
      StartTimer 1
      'Set T1CON = 0x81
    

    Not working!

    I am almost to the point of ordering a different chip or putting a external A/D on the I2C of the old 16F886 which works.

    73
    Mike

     
  • Anobium

    Anobium - 2023-12-19

    It would only be 0x89 if the config was set to SOSC, which it is not.

     
  • mmotte

    mmotte - 2023-12-19

    actually config / init gives it 0x88

    and then the starttimer1 adds the '1' giving 0x89

    where is "high power"? I need to check that.

     
  • Anobium

    Anobium - 2023-12-19

    Open PICINFO, select SOSCSEL. Take the config, post into source.

     
  • mmotte

    mmotte - 2023-12-19
    DataLogger_v12_17_AD8302_18F26K80_siderealRTC.gcb (110): Error: Variable 
    SOSCSEL was not explicitly declared
    

    It is in the chip file but I can not set it to "HIGH".

    I also tried to read "CONFIG1L" which doesn't exist

     
  • mmotte

    mmotte - 2023-12-19

    Where is PICINFO?

     
    • Anobium

      Anobium - 2023-12-19

      From GCODE IDE, press function key <f4>, then type PICINFO, select/press enter.</f4>

      In PICINFO enter your select PIC in the dialog near the bottom/left .
      
      Your PIC will be shown.
      
       
  • mmotte

    mmotte - 2023-12-19
    SERPRINTVAL_H                    EQU      58          ; 0x3A
    SHOURS                           EQU      61          ; 0x3D
    SMINS                            EQU      62          ; 0x3E
    SOSCSEL                          EQU      63          ; 0x3F
    SSECS                            EQU      64          ; 0x40
    STR                              EQU    3400          ; 0xD48
    STRINGPOINTER                    EQU      65          ; 0x41
    SYSARRAYTEMP1                    EQU      66          ; 0x42
    

    SOSCSEL is in the .asm file but no value

     
    • Anobium

      Anobium - 2023-12-19

      If have #option explicit and you have set SOSCEL = 'a value' and it does not have an associated dim the compiler would complain.

      So, it depends what is in your program. I would need the program to figure out.

       
  • mmotte

    mmotte - 2023-12-19

    Yayhhh! That did it. I would never have found that. SOSCCON was bucking me off. I was there before but couldn't make it work.

    It works!

    12:2:0, 16:4:5, 1084,927
    after starttimer1 T1CON = 0x89
    12:2:2, 16:4:7, 217,185
    12:2:8, 16:4:13, 866,742
    12:2:10, 16:4:15, 1083,927
    12:2:12, 16:4:17, 1081,927
    12:2:14, 16:4:19, 1080,926
    12:2:16, 16:4:21, 1081,926
    12:2:18, 16:4:23, 1083,926
    12:2:20, 16:4:25, 1086,925
    12:2:22, 16:4:27, 1089,925
    12:2:24, 16:4:29, 1092,924
    12:2:26, 16:4:31, 1095,924
    12:2:28, 16:4:33, 1097,923
    

    Selecting SOSCCON HIGH and then copying the config into the top of the code did it.

    Now to actually work on my project.
    Thank you!!!
    Mike

     
  • mmotte

    mmotte - 2023-12-19

    Yayhhh! That did it. I would never have found that. SOSCCON was bucking me off. I was there before but couldn't make it work.

    It works!

    12:2:0, 16:4:5, 1084,927
    after starttimer1 T1CON = 0x89
    12:2:2, 16:4:7, 217,185
    12:2:8, 16:4:13, 866,742
    12:2:10, 16:4:15, 1083,927
    12:2:12, 16:4:17, 1081,927
    12:2:14, 16:4:19, 1080,926
    12:2:16, 16:4:21, 1081,926
    12:2:18, 16:4:23, 1083,926
    12:2:20, 16:4:25, 1086,925
    12:2:22, 16:4:27, 1089,925
    12:2:24, 16:4:29, 1092,924
    12:2:26, 16:4:31, 1095,924
    12:2:28, 16:4:33, 1097,923
    

    Selecting SOSCCON HIGH and then copying the config into the top of the code did it.

    Now to actually work on my project.
    Thank you!!!
    Mike

     
  • Anobium

    Anobium - 2023-12-19

    Excellent!

    There is a huge amount of infomation in PICINFO.....

     

Log in to post a comment.