robert campbell
Joined: 31 May 2004 Posts: 3
|
trouble with PORTC on 16f876a |
Posted: Fri Dec 03, 2004 5:43 pm |
|
|
I am using fast io, and am setting the tris reg to 0x90. It seems to revert to 0x97 and an output high operation doesnt change the tris reg back. (Changing the tris reg before this command in C doesnt change the tris reg either). It seems like interference from a peripheral, but I believe they are all turned off. Below are code snippets:
set_tris_A(0x01);
set_tris_B(0x01);
set_tris_C(0x90);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
setup_comparator(CCP_OFF);
SETUP_CCP1(CCP_OFF);
SETUP_CCP2(CCP_OFF);
SET_PWM1_DUTY(CCP_OFF);
SET_PWM2_DUTY(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
port_b_pullups(FALSE);
setup_spi(SPI_SS_DISABLED);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
setup_timer_2(T2_DIV_BY_16,224,16);
enable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
setup_uart(TRUE);
output_low(PING); //I/O STATE CONTROL
output_low(LED);
output_low(PWR);
output_low(OSCPWR);
output_high(IRRXPWR);
sleep_mode = FALSE; //Variable initialization
mag_toggle = FALSE;
mem_full = FALSE;
load_values();
p_and_t_calc();
baud_2400_on();
Read_Cal();
printf("%lu,%lu,%lu,%lu,%lu\r\n",C1,C2,C3,C5,C6);
first_time = TRUE;
c=code[i];
***** By this point the tris reg is 0x97. I try changing it back to 0x90 before the operation which requires C2 to be an output, but toggling other pins on PORTC causes it to reset back to 0x97. (I need C2 to remain high to turn on another device while toggling the other pins)
Please help!
Thanks |
|