PIC16F877A not working again :(


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697

    Default PIC16F877A not working again :(

    Hi, Ive not touched 16F877A's for a while but now i need to use one again and im having more problems with it. Ive written some test code and ive tried mister_e's code from last time. My test code uses portD but ive tested ports A and B with mister_e's code too and im not picking anything up. Ive done all the usual checks (MCLR, Resonator, Capacitor etc). Ive checked the voltage with my oscilloscope and its extremely smooth. It almost looks like theres no load on it at all. The PIC is definately connected to it so im guessing its just not starting up correctly.

    Im sure i got it working last time but i dont know how and im out of ideas now. I dont have any beer this time either . Does anyone have any ideas?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    Hi, Ive not touched 16F877A's for a while but now i need to use one again and im having more problems with it. Ive written some test code and ive tried mister_e's code from last time. My test code uses portD but ive tested ports A and B with mister_e's code too and im not picking anything up. Ive done all the usual checks (MCLR, Resonator, Capacitor etc). Ive checked the voltage with my oscilloscope and its extremely smooth. It almost looks like theres no load on it at all. The PIC is definately connected to it so im guessing its just not starting up correctly.
    Sir...SIR!!!!
    Put down the PIC...now step away from the PIC...Hands behind your ankles...
    Is it in backwards? Ya never, know...could happen...
    And this is my favorite test code...absolutely nothing fancy, but it tells me that things are working...
    Code:
    temp var byte
    trisa = 0  'set all the pins to outputs
    trisb = 0
    trisc = 0
    trisd = 0
    trise = 0
    'also turn analog ports to digital and/or set cmcon if applicable
    main:
    temp = temp + 1
    porta=temp
    portb=temp
    portc=temp
    portd = temp
    porte = temp
    'put a pauseus xxx here if the fastest pin (bit 0 for each port) is entirely too fast
    goto main
    That way each successive pin on each port will have exactly half the frequency of the pin before it. Of course things change with each different type of PIC and it's application, i.e. whether or not I'm using MCLR as MCLR or an I/O, whether or not I'm using OSC1/OSC2 as clock pins or I/O, and so on and so on...
    Last edited by skimask; - 21st October 2008 at 00:01.

  3. #3
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Its not in backwards. I know it can happen, Ive done it pleanty of times myself. Usually i put it in the programmer the wrong way. This is definately correct though. I am using the OSC1 and OSC2 pins for a 3 pin resonator (20MHz). MCLR is being used as MCLR. I dont see any options to use it as an I/O pin on this chip. It has a 10K resistor to VDD.

    CMCON doesnt make much sense to me but that only seems to affect portA. My Code tested portD by turning 2 outputs on and off alternately. mister_e's code tests both portA and portB. I had trouble with portA before but at least portB worked. The only thing i see about portD is that it can act as a parallel port. The datasheet says trisE.4 must be set to enable "PSPMODE" but its default value is 0 so portD should be working as normal I/O pins.

    The values of portD are unknown at startup. Usually that means the LEDs i have connected will flash sometimes when the PIC powers up. This time there not doing. Its like the chip is never turning on. I thought there might be a problem with my breadboard so i tested the power pins on the PIC and there is definately power getting there.

    Ill have a go with your test code when i get home but for now ill continue reading the datasheet to see if there are any other registers that might affect it

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking Copy n' paste backdraw ...

    Ha,Ha,Ha


    ive tried mister_e's code from last time.
    Code:
     ifdef PM_USED
                device  pic16F877A, xt_osc, wdt_on, lvp_off, protect_off
            else
                __config _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
            endif
            endasm

    I am using the OSC1 and OSC2 pins for a 3 pin resonator (20MHz).

    Dit you also try to heat your pic, just some degrees ????

    could be another solution ... the Hardware one

    Alain
    Last edited by Acetronics2; - 21st October 2008 at 10:06.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    I know last time i was using a 4MHz one instead. Whats bad about using that code with a 20MHz?

    The test code i wrote myself has "DEFINE OSC 20" at the top so that should have worked

    Edit: The PIC didnt get noticably warmer at all
    Last edited by The Master; - 21st October 2008 at 10:23.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    I know last time i was using a 4MHz one instead. Whats bad about using that code with a 20MHz?
    The test code i wrote myself has "DEFINE OSC 20" at the top so that should have worked
    Edit: The PIC didnt get noticably warmer at all
    Check the datasheet, Oscillator section in particular...
    Have to change the oscillator configuration from XT to HS when using a higher frequency crystal/resonator/etc.

  7. #7
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Ive got another slight problem with this. Ive just tried to control some optoisolators using porte.0 and porte.2. For some strange reason the pins just wont turn on. I added some test code and the correct data is getting to the chip. It copies a bit from the serial data directly to the pin (EG, porte.0=btemp.0). Right after if i check the status of the pin it shows as 0. Ive had a look in the datasheet and i can see that porte gets used for parallel communications but i have set the tris registers to disable it and use it as a general I/O. I have something else connected to porte.1 and that works fine :S

    Edit: It seems that changing the status of another pin is causing those pins to turn off. I had this the other night with portA too. Turning 1 output on would turn another off automatically. Im going to look through all the code again incase theres a silly mistake somewhere
    Last edited by The Master; - 29th October 2008 at 19:09.

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    What are you doing with the analog settings or pins.?
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Im not using any analogue. The datasheet says analogue is disabled if ADCON1.0 is 0. It also says that its 0 by default.

    I seem to remember these outputs working before by they arnt doing now. Ive not added any code that changes the state of those pins anywhere except the 1 line

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try adding this to the start of your code.

    Code:
    ADCON1=7 
    CMCON=7
    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    That worked Now ive just gotta read the datasheet and find out why

    Thanx

Similar Threads

  1. PIC16F877A PORTA.2 not working
    By The Master in forum Off Topic
    Replies: 2
    Last Post: - 10th October 2009, 18:16
  2. PIC16F877A analog problem
    By DeViLa_Q8 in forum mel PIC BASIC
    Replies: 0
    Last Post: - 30th July 2009, 20:19
  3. PIC16F877A for application in mobile robot...
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th January 2009, 14:47
  4. PIC16F877A not working
    By The Master in forum General
    Replies: 6
    Last Post: - 16th November 2007, 11:32
  5. communicating pic18f452 with pic16f877a
    By tamersoss in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th July 2007, 19:54

Members who have read this thread : 0

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