PIC 18F6620 don't work

Discussion in 'Embedded Systems and Microcontrollers' started by a21, Apr 7, 2010.

  1. a21

    Thread Starter New Member

    Mar 24, 2010
    8
    0
    Hi,
    I have a simple program for testing PIC 18F6620:

    void main()
    {
    SET_TRIS_G(0x00);
    OUTPUT_HIGH(PIN_G3);
    while(1);
    }

    It is done in CCS. I am using 20Mhz crystal with 16pF capacitors. The oscillator is set to HS. The problem is that the PIC is not working. G3 is low. I tried to insert NOP in 0x00, but this didn't help.

    EDIT: I checked OSC1 and OSC2 with oscilloscope and there is 80mV constant level.
     
    Last edited: Apr 8, 2010
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Have you set the configuration bits correct?
     
  3. a21

    Thread Starter New Member

    Mar 24, 2010
    8
    0
    Here is my .h file

    Code ( (Unknown Language)):
    1. #include <18F6620.h>
    2. #device adc=8
    3.  
    4. #build (reset = 0x0002)
    5. #ROM 0 = {0x0000}
    6.  
    7. #FUSES NOWDT                    //No Watch Dog Timer
    8. #FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
    9. #FUSES HS                       //High speed osc
    10. #FUSES NOPROTECT                //Code not protected from reading
    11. #FUSES NOOSCSEN                 //Oscillator switching is disabled, main oscillator is source
    12. #FUSES NOBROWNOUT               //No brownout reset
    13. #FUSES BORV25                   //Brownout reset at 2.5V
    14. #FUSES PUT                      //No Power Up Timer
    15. #FUSES NOCPD                    //No EE protection
    16. #FUSES STVREN                   //Stack full/underflow will cause reset
    17. #FUSES NODEBUG                  //No Debug mode for ICD
    18. #FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
    19. #FUSES NOWRT                    //Program memory not write protected
    20. #FUSES NOWRTD                   //Data EEPROM not write protected
    21. #FUSES NOCPB                    //No Boot Block code protection
    22. #FUSES NOEBTRB                  //Boot block not protected from table reads
    23. #FUSES NOEBTR                   //Memory not protected from table reads
    24. #FUSES NOWRTC                   //configuration not registers write protected
    25. #FUSES NOWRTB                   //Boot block not write protected
    26.  
    27. #use delay(clock=20000000)
    28. #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,stop=1)
    29.  
     
  4. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    The obvious question is do you have the MCLR pin pulled up to Vdd?
     
  5. a21

    Thread Starter New Member

    Mar 24, 2010
    8
    0
    Yes, I have pull up res to Vdd - 1K.
     
  6. a21

    Thread Starter New Member

    Mar 24, 2010
    8
    0
    I don't know does it matters, but PicKit2 shows me User Ids: FF FF FF FF FF FF FF FF
     
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Then you program your device with a PICKIT 2, I am almost sure a verify is performed after the writing. If any error you will be warned. If you can perform a write cycle you can be pretty sure the MCU is OK. I would look for problems in the coding. And of course the hardware setup.
     
    Last edited: Apr 8, 2010
  8. a21

    Thread Starter New Member

    Mar 24, 2010
    8
    0
    I made new PCB and checked all connection, but it doesn't work. Here is my asm code (generated from CCS)
     
Loading...