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

trouble with PORTC on 16f876a

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



Joined: 31 May 2004
Posts: 3

View user's profile Send private message

trouble with PORTC on 16f876a
PostPosted: Fri Dec 03, 2004 5:43 pm     Reply with quote

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
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Fri Dec 03, 2004 5:46 pm     Reply with quote

Please post the complete code or a small but complete program that will demonstrate this.
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