CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Pic16f877A, sporadic working.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Danny.
Guest







Pic16f877A, sporadic working.
PostPosted: Fri Apr 21, 2006 6:16 am     Reply with quote

This is a continuation of a post I made yesterday, but the simple mistake that I made was fixed by suggestions from another poster, so I thought I'd try throwing another question to the community...

I have a PIC16f877A wired to a serial port, (RC6) pin25

Attached to the chip i have,
1 8MHz crystal, connected to a ground through two 22pf capacitors, (arranged like they are in the 16f877 manual.
power connected to both vdd and vss pins, (does anyone know if both of the power supplies *need* to be connected, or are they connected internaly,
I also have a LED (with 4.7K series resistor), on RB0 (annode to VDD cathode to RB0)
my voltage source I'm rtying to measure is on RA0 (pin 2)
and it's all powered by an ATX supply from a computer, (so I can't see that there are supply problems)

Code:
#include <16f877.h>
#device adc=10
#fuses HS,NOPROTECT,NOWDT,NOBROWNOUT,NOLVP
#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,bits=8, INVERT)
unsigned char j;
void main(void)
{
   int16 result;
   set_tris_a(0xFF);
   setup_adc_ports(0);
   setup_adc(ADC_CLOCK_DIV_8);
   set_adc_channel(0);
   while(1)
     {
      output_high(PIN_B0);
         result = read_adc();
         printf("voltage is: %lx\n\r", result);
         delay_ms(500);
      output_low(pin_B0);
         delay_ms(500);
     }
}


The problem is that it only seems to work when it wants to.

that is to say, it won't necessarily work when it's first powered up, but will the spring into life (returning reasonable data to the terminal), the just as suddenly stop again, (no lights no data)...

I've looked and searched and googled, and can't seem to find anything remotly like the problem that I'm having.

Does anyone have any ideas?
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Fri Apr 21, 2006 7:05 am     Reply with quote

Which output from the ATX power supply are you using? How is it hooked to the board. Which RS232 transceiver are you using?

Can you show us a schematic?
Charlie U



Joined: 09 Sep 2003
Posts: 183
Location: Somewhere under water in the Great Lakes

View user's profile Send private message

PostPosted: Fri Apr 21, 2006 7:08 am     Reply with quote

First, I'd add PUT to the fuses. This is the power up timer that delays the internal reset until (in theory) the crystal oscillator has fully started. This should not help the intermittent problem, but should be done anyway.

Next, how is your MCLR pin connected? This sounds like your MCLR pin is not connected properly or may be loose.
Guest








PostPosted: Fri Apr 21, 2006 7:39 am     Reply with quote

thanks to you both!!
Very Happy
the problem was that the MCLR pin was not connected, (and floats high?).

Now it's all connected and working, so thats great, thanks guys!!



The atx power supply...?
I've long jumper leads from my breadboard pushed into the pins of the floppy connector (+5 red and 0 black), and a paperclip shorting pins 14 and 15 (green and black) on the main socket to make it constantly on... (I will re house this eventually but it works for now...)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group