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

Help with PIC12508

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



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

Help with PIC12508
PostPosted: Fri Jul 16, 2004 4:23 pm     Reply with quote

Sad Hi all
I seem to be going crazy with the simplest code I have ever written, but I cannot get it to work. The code is supposed to perform a very simple function: Toggle GP5 port from high to low for 20 mS and then back to high whenever a high to low transition is detected at either GP0 or GP1, That is all!!! When I program a device it seems that the output (GP5) pin is sitting at half the supply, just as if it was in a tri-state or input mode, it never toggles. I have read the data sheet and I cant see why? Perhaps there is a very simple blunder in my code, that I just can't see. The electrical connectivity is OK. The code is listed below

Thanks for your help

#include <12C508.h>
#fuses INTRC, WDT, XT, MCLR
//#rom 0x1ff={0xA00C}
#use delay(clock=4000000,RESTART_WDT)
//#define SWPWR 48
//#define EXTPWR 49
//#define PWRINT 50

#byte GPIO = 0x6
#bit SWPWR = GPIO.0
#bit EXTPWR = GPIO.1
#bit IO2 = GPIO.2
#bit RST = GPIO.3
#bit OUT4 = GPIO.4
#bit PWRINT = GPIO.5
#define ON 1
#define OFF 0
//#use fast_io(b)


void init()
{
setup_timer_0(RTCC_INTERNAL);
setup_wdt(WDT_72MS);
set_tris_b(0b00001111);
//output_high(PWRINT);
PWRINT = ON;
}


void main()
{
init();
delay_ms(50);

do{
if(!SWPWR)
{ PWRINT = OFF;
delay_ms(20);
PWRINT = ON;
delay_ms(1000); }

if(!EXTPWR)
{ PWRINT = OFF;
delay_ms(20);
PWRINT = ON;}


restart_wdt();

} while(1);

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 16, 2004 4:57 pm     Reply with quote

I don't have the PCB compiler, but this line right here, looks
incredibly suspicious:

#fuses INTRC, WDT, XT, MCLR

You've got two oscillator settings in the #fuse statement.
I don't know what the compiler would do about that.
It might just use the XT setting, since it's the last one to
be found as the line is scanned. If you're depending on
using the internal RC oscillator, then the PIC would not run.

Get rid of one of those settings. Use either XT or INTRC,
but not both.

For a list of the oscillator configurations, look at section 8.2
of the 12C508 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/40139e.pdf
Ttelmah
Guest







PostPosted: Sat Jul 17, 2004 2:15 am     Reply with quote

PCM programmer wrote:
I don't have the PCB compiler, but this line right here, looks
incredibly suspicious:

#fuses INTRC, WDT, XT, MCLR

You've got two oscillator settings in the #fuse statement.
I don't know what the compiler would do about that.
It might just use the XT setting, since it's the last one to
be found as the line is scanned. If you're depending on
using the internal RC oscillator, then the PIC would not run.

Get rid of one of those settings. Use either XT or INTRC,
but not both.

For a list of the oscillator configurations, look at section 8.2
of the 12C508 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/40139e.pdf


Also if this is an eraseable chip (the UV EEPROM version), remember that you _must_ save and restore the 'OSCCAL' value for INTRC to work, when you erase the chip.

Best Wishes
cbarberis



Joined: 01 Oct 2003
Posts: 172
Location: Punta Gorda, Florida USA

View user's profile Send private message Send e-mail

PostPosted: Sat Jul 17, 2004 10:38 am     Reply with quote

It goes to show that the simplest things in life can sometimes be the most difficult! I spent hours trying to figure out why this little pic would not work. I knew it was something so stupid, that the stupid could not see. DUH!!!!

I tested it after removing the extra XT setting on the fuses and now it works fine!

Once again Thank you! Very Happy
Guest








PostPosted: Sat Jul 17, 2004 11:23 am     Reply with quote

Hi cbarberis,

As stated by PCM Programer, the clue is in the #fuses directive.
Quote:

#fuses INTRC, WDT, XT, MCLR


The compiler doesn´t realize regarding multiple Xtal configurations,
BUT it validate the last one, in your case XT. As you don't have any Xtal
mounted in your board, you can imagine that nothing is running.

Best regards,

Humberto
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