Menu

Problem with PIC 18 F 1220

Help
Capaction
2010-12-19
2013-05-30
  • Capaction

    Capaction - 2010-12-19

    GCBASIC with this code gives the asm and hex files with no error.

    #chip 18f1220,8
    #config LVP = ON, MCLRE = OFF, WDT = OFF, OSC = INTIO2
    #define Led PortA.4
    dir PortA.4 out
    Main:
    Set Led On
    wait 1 s
    Set Led Off
    wait 1 s
    Goto Main

    This programm does not blink the Led as expected.
    I measured 5 volts on pin4  Vpp and pin 14 Vdd but cannot see something on pin 16 OSC2   with the scope !

    Where should I search to fix this ?

     
  • kent_twt4

    kent_twt4 - 2010-12-19

    Have to look at the 18f1220 data sheet, I/O Ports section to see this one.  Wah?, RA4 (pin 3) is an open drain output pin!  Can't say I have crossed paths with one before on a PIC, but I,m sure they are out there somewhere.

    One way to blink the led is to supply the led with 5V to a resistor + led anode, and then hook up the led cathode to R4.

     
  • kent_twt4

    kent_twt4 - 2010-12-19

    Oh right, now I remember, THE RA4 pin.  Same as the older 16f devices, like the 16f628a , 16f877a, and many others.

     
  • gcha44

    gcha44 - 2010-12-19

    Hi,
    if you take a look at 18F1220 datasheet , you can read:
    "RA4/T0CKI bit4 ST Input/output, external clock input for Timer0. Output is open drain type."

    It seems that configuration is correct . But if there is no signal on RA6 pin , i think the processor is in iddle or sleep mode .(why ??)

    because ,datasheet says :
    "• In INTIO2 mode, OSC1 functions as RA7 and
    OSC2 functions as RA6, both for digital input and
    output."

    So ,you can configure manually OSCON register to try starting 18F1220 ( see chapters 2.0 and 3.0 of Microchip datasheet)

    Regards
    GC

     
  • Capaction

    Capaction - 2010-12-21

    I tried  starting the clock as you suggested:

    #chip 18f1220,8
    #config LVP = ON, MCLRE = OFF, WDT = OFF, OSC = INTIO2
    OSCCON = b'01110000'

    And I do not get the clock  signal on RA6

    regards,

     
  • gcha44

    gcha44 - 2010-12-21

    Hi,
    I think you'll try to configure LVP=OFF or you must   ground  PGM(RB5) pin to enable normal program .Because in chapter 19.9 : "low voltage ICSP programming"of 18F1220 datasheet , you can read :

    "3: When LVP is enabled, externally pull the
    PGM pin to VSS to allow normal program
    execution."

    but if  LVP=OFF

    "If Low Voltage Programming mode will not be used, the
    LVP bit can be cleared and RB5/PGM becomes available
    as the digital I/O pin RB5. The LVP bit may be set
    or cleared only when using standard high voltage programming
    (VIHH applied to the MCLR/VPP pin)."

    regards,

     
  • Capaction

    Capaction - 2010-12-22

    Thank you gch44;  you put your finger on one of my problems. The LED blinks now with this code:

    #chip 18f1220,8
    #config LVP = OFF, OSC = INTIO2
    OSCCON = b'01110000'

    Dir PortA.4 OUT2
    #Define LED PortA.4

    Main:
    Set Led On
    wait 1 s
    Set Led Off
    wait 1 s
    Goto Main

    I had to put away my USB-Programmer working on ISCP and use a ICD2 clone.

    Although the LED blinks I was unable to see a signal on pins 16 & 15 ie OSC1 & OSC2
    I don't know which set up will  show the clock on the scope ie TimeBase, Volts … I am new on this.

    I checked the MicroChip dataSheet  against  the 18f1220.dat file coming with GCBASIC, the pin assignments do not match !
    I am expecting other problems in my code migration from the 16F628A to the 18F1220.

     
  • gcha44

    gcha44 - 2010-12-22

    Hi,

    Perhaps can you try now to delete OSCCON='b01110000' and let GCBasic configuring itself OSCCON register  . Because when you write #chip 18F1220, 8 , GCBasic sets bits 6-4 of OSCCON .

    I also think that you must config OSC=INITIO1 if you want to have Clockout on RA6 because  :

    "INTIO1 Internal Oscillator with FOSC/4
    output on RA6 and I/O on RA7" (datasheet 18F1220)

    but with OSC=INITIO2 , RA6 is a I/O port as others

    "INTIO2 Internal Oscillator with I/O on RA6
    and RA7" (datasheet 18F1220)

    Then  you'll see a 2Mhz signal on RA6 !

    18F1220 configuration is more difficult that 16F628 's !

    regards 

     
  • Capaction

    Capaction - 2010-12-24

    OK gcha44  GCBASIC do not need OSCCON = b'01110000'  and compile fine with only
    #chip 18f1220,8
    #config LVP = OFF, OSC = INTIO2

    However if i state OSC = INTIO1 the code works also but there is no clock signal on RA6, just 5volts.
    I suffer with this PIC18F1220

     
  • gcha44

    gcha44 - 2010-12-24

    If there is no clock signal on RA6 when OSC=INTIO1 , only take care than fuses are correctly programmed in the checkbox  of your programmer .
    Have a look at chapter :

    19.0 SPECIAL FEATURES OF THE

    CPU of 18F1220 datasheet

    Sorry , I don't see another reason .
    GC

     
  • Capaction

    Capaction - 2011-01-04

    Thank you gcha44
    I  get now  the signal on OSC1 pin.
    The problem was on my PCB:   10k resistor and 27pf capacitor  missing on pin 16 OSC1

     

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.