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 CCS Technical Support

16f88 Pin 9 (CCP1) tied high locks up PIC

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



Joined: 14 Mar 2008
Posts: 1

View user's profile Send private message Yahoo Messenger

16f88 Pin 9 (CCP1) tied high locks up PIC
PostPosted: Fri Mar 14, 2008 4:35 pm     Reply with quote

I have a simple F88 circuit. Pin 9 has a 10k pullup on it. When I connect this pin, the PIC locks up. When I let it float, my code runs fine.

Using RS232 on RA2 and RA3.

I'm pretty sure the problem is in the initialization and set up code, but it isn't clear how to disable CCP1

Clues?

Code:
void main()
{
unsigned char c, cmd[15],command;
int i,x,y = 0;

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_ccp1(FALSE);
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);
setup_oscillator(False);
set_tris_b(0x00);
set_tris_a(0x0f);

while(1){
puts("CMD: ");

i=0;
c = getchar();
cmd[i] = c;

while ( c != CRLF ) { // read a command string
i++;
if(i == 20)
i=0;
c = getchar();
cmd[i] = c;
}


if (i>20) {
i=0;
puts("Error\n\r");
} else {
command=cmd[0];
switch (command)
{
case 's': // set a relay
x=(cmd[1]-'0');
printf("setting %d %c\n",x,cmd[1]);
set_relay(x);
puts("Set!\n\r");
break;
case 'c': // clear a relay
clear_relay(cmd[1]-'0');
puts("Clear!\n\r");
break;
case 'a': // clear all relays
clear_all_relays();
puts("Clear all\n\r");
break;
case 'l': // set all relays
set_all_relays();
break;
default: i=0;
break;
}
}
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 14, 2008 4:40 pm     Reply with quote

Quote:

I have a simple F88 circuit. Pin 9 has a 10k pullup on it. When I connect
this pin, the PIC locks up.

Yes, that's exactly what happens. Microchip decided to cost us one
million lost engineering hours (or student hours) by putting in a "low
voltage" programming mode that hardly anyone uses, and to enable
it by default.

Always post your #fuses. Much of the time, that's where the problem
will be. To fix your problem, add the NOLVP setting to your #fuses
statement. Do this in all your programs. In recent versions of the
compiler, CCS has started setting the fuse to NOLVP by default. So if
you forget to specify NOLVP, the compiler will do it for you. But you
have an earlier version, so you need to set it in the #fuses.
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