PIC programs, resonator resonates, but does not run code.


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default PIC programs, resonator resonates, but does not run code.

    Baffling problem. The code was tested fine on an 18 pin 18F1320 on a breadboard, the pcb uses a 20 pin 18F1320. The 20mhz resonator runs perfectly. A test program using internal RC doesnt run either. I can program and read back the code and it verified ok. Also, this is 2 different PIC's in a row.

    Any ideas what the heck the issue is? Anyone seen this before?

    Here is a short test program to turn on and off a pin:

    Code:
    Define OSC 20
    
    ADCON1 = %01111000
    ADCON2 = %10000111
    
    TRISA = %11100111
    TRISB = %11000011
    
    loop1:
    portb.2 = 1
    pause 100
    portb.2 = 0
    goto loop1
    I'm programming using HS just as I did on the breadboard. MCLR is set as an input.

  2. #2
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    Add another PAUSE 100 to your test loop so you can see it go low.
    Code:
    loop1:
    portb.2 = 1
    pause 100
    portb.2 = 0
    PAUSE 100
    goto loop1
    Louie

  3. #3
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    Thanks.

    It never actually goes high though.

  4. #4
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    Well, a third PIC shows the exact same behavior. It will program and verify fine but will not execute code. I changed the resonator, same result. Will try a new pcb next.

  5. #5
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    New pcb, new PIC, same result. Only populated the board with a 5v regulator and caps, plus resonator and PIC. Layout is good. Can program, verify, read back, erase etc etc. Again, resonator is showing clean 20mhz waveform, it just will not execute the code.

  6. #6
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    Try this please;

    Code:
    loop1:
    LATB.2 = 1
    pause 100
    LATB.2 = 0
    PAUSE 100
    goto loop1
    Also check if MCLR is connected to VCC. I don't see the configuration bits of your code!
    Last edited by gadelhas; - 8th August 2012 at 22:32.
    Thanks and Regards;
    Gadelhas

  7. #7
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    Confusing since it worked on the 18 pin but I would also try configuring in the order shown in Example 10-2 of the data sheet:
    Code:
    PORTA = %00000000       ' Turn off all PORTA 
    PORTB = %00000000       ' Turn off all PORTB
    ADCON1 = %01111000
    ADCON2 = %10000111
    TRISA = %11100111
    TRISB = %11000011
    Louie

  8. #8
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    Let's look at the code that works. Maybe theres something you left out...
    Dave Purola,
    N8NTA
    EN82fn

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    The 20-pin version has separate AVSS and AVDD pins.
    Did you connect them to VSS and VDD?
    DT

  10. #10
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PIC programs, resonator resonates, but does not run code.

    Fixed!

    So it would appear if you use the auto insert serial number feature it changes your config bits during programming. This applies to the U2 programmer software. Uncheck this feature, problem solved, and the design functions just fine.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts