Menu

PIC18LF24J11 programming

G. C.
2023-12-20
2023-12-31
  • G. C.

    G. C. - 2023-12-20

    Hello,
    I am making some tests with a PIC18LF24J11 and an LCD 16x2 with a very simple program.. I get it compiled but not transferred to the PIC. I am sure all the wiring (both power and ICSP) is correct, but the compiler tells me this:

    Error 3: Did not find a PIC18LF24J11. Check that you have power.

    Question: is there something special to do when programming the 3.3Volts devices? I am using PICKit2..

    Thanks and rgds,
    GC

     
  • Anobium

    Anobium - 2023-12-20

    I need a bit more info.

    PICKItPlus or not?
    Have you selected PICKit+ Cmd3v3 [Maintain Power @ 3v3] as the programmer interface ( if using PK+)?

    Share the top few lines of the ASM. It will reveal lots.

    It will look like this.

    ;********************************************************************************
    ;   Source file    : GLCDProgram.gcb
    ;   Setting file   : C:\GCstudio\gcbasic\use.ini
    ;   Preserve mode  : 2
    ;   Assembler      : "C:\Program Files\Microchip\xc8\v2.45\pic-as\bin\pic-as.exe"
    ;   Programmer     : C:\GCstudio\gcbasic\..\PICKitPlus\PICKitCommandline.exe
    ;   Output file    : D:\GreatCowBASICGits\Help.git\trunk\seven_inch_gcld\code\gcbasic\GLCDProgram.asm
    ;********************************************************************************
    
     
  • G. C.

    G. C. - 2023-12-20

    Yes, Pickit+ and Mantain Pwr at 3.3V.

    Attached the source/asm

     
  • Anobium

    Anobium - 2023-12-20

    I remember.

    When we test PK+ the J11 requires external power. Please try with external power.

     
  • G. C.

    G. C. - 2023-12-21

    It was always powered, but with the 3.3V only.. I found out that the LF models require a 2.5V supply on the VDD Core pin. Added this voltage to the pin, but still was not able to program the chip via PICKIT2 and PICKitPlus sw..

    So I tried with an ICD3 and Microchip IPE, finally being able to load the hex produced by GCB onto the chip. However this little program does not work, perhaps the interface to the LCD (that works at 5V, yet another supply voltage) is not good.. I used only the 5V tolerant pins of the uC, but it seems not working anyway.
    Perhaps it's better to change the chip - I had a couple of these to try, only models in my drawer that had an RTC on board. I'll buy some newer ones working at 5V only, with RTC on board.
    Rgds,
    GC

     
  • Anobium

    Anobium - 2023-12-21

    See the attached - this may explain.

     
  • G. C.

    G. C. - 2023-12-23

    FYI:

    I set up everything correctly and now get LCD prints etc..

    So I proceeded with setting Timer1 in order to give a 10mSec interrupt..
    But I found that using the statement #chip 18LF24J11, 8 I do not get the right results , but a lower input freq to Timer1 clock input...
    I guess there is something to correct in the Timer.h file, as in the command InitTimer1 the keyword Fosc does'nt get recognized from the compiler..

    If I use #chip 18LF24J11, 8 and InitTimer1 FOsc4, PS1_1 do not get the right Interrupt timing,
    So I had to write directly into OSCON bits like this:
    IRCF0=1
    IRCF1=1
    IRCF2=1
    In order to get system clock at 8MHz..

    and then InitTimer1 FOsc4, PS1_1 wich is accepted by the compiler. In this way I get the right timing of 10 msec interrupt.

    Main attached for reference..
    Rgds and Happy Holydays!
    GC

     
  • G. C.

    G. C. - 2023-12-28

    Found another problem with 18LF24J11: Can't get an external interrupt..

    The little program attached here generates a 2Hz wave on portc.3, wich is connected directly to RB0/INT0 pin 21 in order to get a rising edge interrupt every second.. Then the sequence should get printed on an LCD.

    The output of the Timer1, sent to Portc.3 is present, but there is no way to get an INT0 fired..
    What am I doing wrong?

    Thx and rgds,
    GC

     
  • Anobium

    Anobium - 2023-12-28

    I am not sure what is meant to happen, so, can you look at the attachment.

    Does this work in terms of firing the interrupt? Then, we know the timer1 is overflowing as expected. When this works then add the RB0 toggle to generator the signal.

     
  • G. C.

    G. C. - 2023-12-28

    In my version (previously attached) the Timer was already working fine..
    It generates the correct output on portC.3, a wave at 2Hz.

    But connecting Portc.3 output to pin 21 (INT0), it does not fire the EXTInt0 interrupt..
    I tried also with a pushbutton, but it does'nt work either. It seems that INT0 is never enabled at all.

    It is expected that the rising edge of the wave should generate an int0 per second, and the cumulating sequences should be printed on the LCD.

     
    • Anobium

      Anobium - 2023-12-28

      OK. I have added the ext int code. What happens ?


      I do not have one of these old chips... so, be patience. :-)

       
  • G. C.

    G. C. - 2023-12-28

    Same thing.. Timer1 works, INT0 not fired/counted..

     
  • Anobium

    Anobium - 2023-12-30

    See later post for the .H.

    Looks to me that the INT port is analog not digital. Try the attachment. I have revised to manage the ports for this legacy chip family.

    This may resolve this issue but I think that the READAD() functions may need an update/edit to sort for analog operations.

    The issue here... not many use the J11 chipset.


    Copy the attachment to you include/lowlevel folder, replacing the existing file.


    Let me know if this resolves.

     

    Last edit: Anobium 2023-12-31
  • G. C.

    G. C. - 2023-12-30

    OK, I finally understood the problem, thanks to your suggestion...

    I gave for grant that once in my code I put the statement " dir portb.0 in " the relative pin was defined as being a DIGITAL input by the compiler...

    It's not so: one has to make sure the pin it's not directed to the analog section..

    To solve the problem, it has been oly necessary to add to my source this line: PCFG12=1. This defined the pin RB0/INT0 as digital, as per default (datasheet images) the uC sets it as analog. Now interrupt fires and the sequences counted as expected.

    I suggest to put into the help, under the "miscellaneous commands/DIR section " a couple of rows that specify to the user that he has to take care to define the pin as pure digital (by setting the appropriate registers bits) when is defined as INPUT with the DIR command..

    Thanks a lot, wish you an Happy New Year.
    GC

     
    • Anobium

      Anobium - 2023-12-30

      Good to hear. Excellent.

      Did you try the new system.h ? I think it may resolve the issue without the additional line of code.

      I ask as this is intended to resolve the issue forever.

      If it fails let me know and I will revise until it does work.

       

      Last edit: Anobium 2023-12-30
  • Anobium

    Anobium - 2023-12-31

    A corrected System.h file.

     
  • G. C.

    G. C. - 2023-12-31

    With this last version of system.h it works correctly, with the preceeding one it was not. It required again the addition of the PCFG12=1 statement.

    Can you please clarify me if the DIR actually defines the pin to be digital, without the need of the other code line? Just to understand it for future programs with any processor I will select..

    One final note: setting the 8MHz clock still needs the 3 lines
    IRCF0=1
    IRCF1=1
    IRCF2=1
    the command #chip 18LF24J11, 8 is not producing the right frequency.

    Best,
    GC

     
    • Anobium

      Anobium - 2023-12-31

      Great news re sytem.h


      DIR sets as INput or OUTput.
      The new system.h sets the ports as digital not analogue. GCBASIC should set all ports to digital and GCBASIC should set to analogue when required in ADC ops. As the J11 is not a highly use chip the setting for the digital where not included. They now are.


      8mHz. Yes. This would require another update to system.h to set the frequency. If you want to send me a spare J11. Then, I can add. At the moment system.h does not set the J11 frequency. The clue is the message OSC: , 8Mhz (Clock source is not a primary internal oscillator. Ensure the clock source is correctly setup) when PICINFO shows the internal frequencies are 8,4,2,1,.5,.25,.125.

      So, a chip here would help to resolve. The compiler needs to learn ( that means I need to understand what is NOT happening correctly ).

      Evan

       

Log in to post a comment.