16f877a porta.5 resets chip


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2008
    Posts
    15

    Default 16f877a porta.5 resets chip

    I am working with a 16f877a and everything works great with my program, but when I take porta.5=0 to run the program, it's like the mclr resets. All other ports are like this using a 5k pullup resistor. After it resets, program runs perfect untill i ground ra5 again.

    osc 20
    adcon=7 digital off
    cmcon=7

    is there something special about porta.5 that does this?

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi lecoind,
    Since I don't know you I won't assume you Do/Do Not know anything, so pardon me if I cover anything that is Old Hat to you.
    Oscillator:
    Code:
    DEFINE OSC 20
    This chip has No ADCON it has ADCON1 & ADCON0
    Code:
    ADCON1 = 7 ' All analog off seven or six, ports as digital
    ADCON0 = 0 ' bits 6:7 control A/D Conversion Clock
               ' bits 3:5 select AN Channels
               ' bit 2 is A/D Go/Done 0 = done
               ' bit 1 unimplemented
               ' bit 0 ADON powers up or shuts down A/D
    Last edited by Archangel; - 29th September 2009 at 02:50.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    interupt jump into a none interupt routine?
    Are you using interupts?
    Have you tried disabling all interupts?

    RA5 is used for...
    Digital I/O.
    Analog input 4.
    SPI slave select input.
    Comparator 2 output

    ok, are you using SPI?
    are you doing anything with comparator 2?
    do you have RA5 set to digital?

    Have you tried moving the RA5 input to another pin?

    This is my chunk of code to setup analogue ports and disable interupts, Perhaps it will help...

    Code:
    ' Setup chip
    ADCON0.6 = 1					' ADC clock set to Fosc/64
    ADCON0.7 = 1					' ADC clock set to Fosc/64
    ADCON1.6 = 0					' ADC clock set to Fosc/64
    INTCON = 0						' Disable all interupts
    TRISE = %00000111				' Set PortE to all inputs
    TRISD = %00000000				' Set PortD to all outputs
    TRISC = %00000000				' Set PortC to all outputs
    TRISB = %00000000				' Set PortB to all outputs
    TRISA = %11111111	 			' Set PORTA to all input
    ADCON1 = 0 					' PORTA is analog
    Consulting 877A's idiots guide now...
    Code:
    Address Name     Bit 7    Bit 6    Bit 5  Bit 4  Bit 3    Bit 2       Bit 1    Bit 0 
    1Fh       ADCON0 ADCS1 ADCS0 CHS2 CHS1 CHS0   GO/DONE —       ADON 
    9Fh       ADCON1 ADFM  ADCS2  —     —      PCFG3 PCFG2     PCFG1 PCFG0
    so ADCON1 = 7 means...
    PCFG0 = 1
    PCFG1 = 1
    PCFG2 = 1
    PCFG3 = 0

    Acording to the datasheet, the value your sending ADCON1 00000111 is sortof invalid...
    The closest match to it is 0000011x where x is "unknown". The purpose of this value is to set port A to all digital...

    Try adding
    Code:
    TRISA = %00000000
    After your ADCON's. This will make port A all digital outputs and will correct any possible miss-configurations...

    Info found on search
    Note: When using the SSP module in SPI Slave mode and SS enabled, the A/D converter must be set to one of
    the following modes, where PCFG3:PCFG0 = 0100, 0101, 011x, 1101, 1110, 1111.
    Found a 'conflict' with PSP port and PCFG0:PCFG2 registers
    Last edited by comwarrior; - 30th September 2009 at 01:31.

  4. #4
    Join Date
    Sep 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Default if all digital

    Great info, I have no analog or comparators.. What would be the best commands for everthing digital so I can test it in that mode. I always get confused with the data sheets. Thanks so much, leon

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lecoind View Post
    Great info, I have no analog or comparators.. What would be the best commands for everthing digital so I can test it in that mode. I always get confused with the data sheets. Thanks so much, leon
    Like Joe said
    ADCON1 = 7 ' All analog off seven or six, ports as digital
    AND
    Code:
    CMCON = 7
    Will make the chip non analog.
    Dave
    Always wear safety glasses while programming.

  6. #6


    Did you find this post helpful? Yes | No

    Default

    I could be wrong, but doesn't a TrisA=00000000 command reset the analogue registers?

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by comwarrior View Post
    I could be wrong, but doesn't a TrisA=00000000 command reset the analogue registers?
    Sort of...
    TRISX sets input or output. But not the type of input.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. servo motor resets 16f877a
    By burak450 in forum mel PIC BASIC Pro
    Replies: 85
    Last Post: - 19th October 2008, 22:25
  2. TV Display Chip
    By zadok in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 17th April 2008, 22:17
  3. Replies: 32
    Last Post: - 23rd March 2007, 04:01
  4. Clock connection to DS1802 from 16F877A
    By coyotegd in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd January 2006, 18:52
  5. chip selection aid
    By PICMAN in forum General
    Replies: 4
    Last Post: - 21st February 2005, 18:33

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