Menu

Millis library with PIC18F4520.

Help
Adrian
2023-10-18
2023-10-25
  • Adrian

    Adrian - 2023-10-18

    Hello from Argentina! Excellent work with GCB.
    I'm testing the Millis library and I can't get it to work on a PIC18F4520, it compiles fine but the LED doesn't blink.
    All the other examples I tried work fine.
    Greetings, Adrian.

     
  • Anobium

    Anobium - 2023-10-18

    Good spot, looks like these 18F chips have not tested with this function.

    As I do not have one of these chips please add script to your program, as shown below.

    #script
      // Alias references to T0CON1 to T0CON. This is required for old 18F microcontrollers
      if NOVAR(T0CON1) Then
        if VAR(T0CON) Then
          T0CON1 = T0CON
        end if
      end If
    #endscript
    

    This will treat all the library references to TOCON1 to TOCON for these chips.

    Please test and let me know if this resolves as we should add to timer.h library... if it works.

     
  • Adrian

    Adrian - 2023-10-21

    Good evening, sorry for the delay in responding.
    I tried the script and it didn't work, so I read the "millis.h" library and saw that Timer0 doesn't start on the 18F4520.
    I added the line to start Timer0 "InitTimer0 Osc, PS0_16" to the code using the oscillator speed in "PS0" and it started working.
    Thanks for the quick reply.

     

    Last edit: Adrian 2023-10-21
  • Anobium

    Anobium - 2023-10-21

    Thank you, but this is a good workaround.

    Try the revised millis.h library and remove the InitTimer0 line from the main program.

    The issue was the script that determines whether a chip has a Pre and Post scaler was incorrect for your chip family.

    Try, test and let me know if resolved.

     

    Last edit: Anobium 2023-10-21
  • Adrian

    Adrian - 2023-10-25

    Good evening, I tried the modified "millis.h" library without adding "InitTimer0" to the code. Tested on PIC12F629, 675, 683; 16F84A, 628A, 88, 818, 873A; 18F4520, 18f4620 and it works perfect.
    Thank you very much Anobium, for the quick response.

     

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.