|
|
View previous topic :: View next topic |
Author |
Message |
bownes
Joined: 14 Mar 2008 Posts: 1
|
16f88 Pin 9 (CCP1) tied high locks up PIC |
Posted: Fri Mar 14, 2008 4:35 pm |
|
|
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
|
|
Posted: Fri Mar 14, 2008 4:40 pm |
|
|
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. |
|
|
|
|
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
|