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

Chip is not getting programmed...

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



Joined: 18 Oct 2006
Posts: 9

View user's profile Send private message

Chip is not getting programmed...
PostPosted: Tue Oct 31, 2006 4:04 pm     Reply with quote

I have the PIC16F877A and every time I program it with MPLab everythign programs fine, but when I try the chip it does not work.

For example...here is the code...

#include "XXXX\AC Zoned.h"


void main()
{

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);



while (1 == 1)
{

if (PIN_B1 == 1)
{

output_high (PIN_D0);
output_low (PIN_D1);
output_low (PIN_D2);
output_low (PIN_D3);

}

else if (PIN_B1 == 0)
{

output_low (PIN_D0);
output_high (PIN_D1);
output_high (PIN_D2);
output_high (PIN_D3);

}
/////////////////////////////////////////////////////////////////
} //end while loop
} //end program

When I apply 5V to pin B1 nothing happens, all it happens is that most of the pins in the whole PIC read about 1.98-2.12V. Pins D1-D3 and most of the other pins read the same ~2V.

My header file lloks like this...

#include <16F877A.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,HS, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, NOWRT

Do you guys see anythig wrong with this?

One more point is that Im using the chip outside the Olimex package, if that matters. Im powering the chip with 5V and connecting the crystal, where it belongs and connecting MCLR to 5V through a 1K resistor.

Any help will be appreciated...

Sorry for the longggg post.

TIA!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 31, 2006 4:29 pm     Reply with quote

I wonder if the PIC's oscillator circuit is running. You connected a
crystal but you didn't mention the 22 pF capacitors that need to go on
each side of the crystal, to ground. Do you have those installed ?

What is the "Olimex package" ? If you're using an Olimex board,
then post the part number of the board so we can look at the schematic.
xcamarox



Joined: 18 Oct 2006
Posts: 9

View user's profile Send private message

PostPosted: Tue Oct 31, 2006 6:53 pm     Reply with quote

PCM Programmer, thanks for the quick reply... yes I did install the 22pF capacitors between the oscillator legs and ground...It is the Olimex BOARD, not package (excuse my ignorance). I was wondering the same about the crystal. The funny thing is that it is connected right...

The Olimex is this one....http://www.olimex.com/dev/pic-p40.html...
xcamarox



Joined: 18 Oct 2006
Posts: 9

View user's profile Send private message

PostPosted: Tue Oct 31, 2006 7:12 pm     Reply with quote

Actually I posted my connections in this ftp server if you want to take a look at them...

ftp://65.83.142.219
User: PCM
Pass:1234

Thanks.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Oct 31, 2006 8:40 pm     Reply with quote

How do you know its not working?

Are you using a logic probe?

Are you using a cro?

If you are just using a multimeter you will not see anything useful.

Try this

Code:

while (1 == 1)
   {
   if (PIN_B1 == 1)
     {
     output_high (PIN_D0);
     output_low (PIN_D1);
     output_low (PIN_D2);
     output_low (PIN_D3);
     }
  else
    {
    output_low (PIN_D0);
    output_high (PIN_D1);
    output_high (PIN_D2);
    output_high (PIN_D3);
    }
  delay_ms(1000);
}

_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Guest








PostPosted: Wed Nov 01, 2006 9:02 am     Reply with quote

asmallri, thanks for the time to look into this.

I know its not working because the pins (D0, D1, D2, etc...) do not do what they are supposed to do (turn on or off through LED's). I will try the delay and report back. At this point anything helps because Im lost.

Thanks guys for your time once again.

I will report back.
xcamarox



Joined: 18 Oct 2006
Posts: 9

View user's profile Send private message

PostPosted: Wed Nov 01, 2006 1:19 pm     Reply with quote

Still, no dice. The chip is not getting programmed. It is getting powered but when I put 5V on B1 and nothing happens to D1-D3...

Any insights?

TIA!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 01, 2006 1:42 pm     Reply with quote

Quote:
Still, no dice

Code:
if (PIN_B1 == 1)

That line of code is comparing two dissimilar constants.
The expression will always evaluate to FALSE.
The if statement will never execute.

You have to use the input() function to read a pin.
xcamarox



Joined: 18 Oct 2006
Posts: 9

View user's profile Send private message

PostPosted: Wed Nov 01, 2006 3:50 pm     Reply with quote

PCM as always the genius you are, solved the problem.

Thanks a lot bud, I really appreciate it. Excuse my stupid code.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 01, 2006 3:54 pm     Reply with quote

It's not genius. I didn't expect code with that level of a mistake in it
so it took me a while to downshift mentally enough to see it.
Guest








PostPosted: Thu Nov 02, 2006 6:03 am     Reply with quote

Hi,

As a side comment, the extra complication of the Input() statement got you into trouble during basic troubleshooting. In the future, I'd recommend that you reduce your test program to it's simplest form (lighting an LED, and then looping indefinitely, for example) to validate the basic functionality of your circuit. In your example, a very simple programmatical error forced you to conclude that your PIC was totally dead. That is a bad design!

Tim
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