Dear Ed, It depends on the chip your are using...for example if it is PIC16F877 then there is some registers associated with PORTA...inorder to set up PORTA in a specific configuation first you have to configure the associated register(s), for the chip above ADCON1 reg. is the associated reg. for example if you want to configure RE2,RE1,RE0(from PORTE) as Digital I/O and RA1,RA0(from PORTA) as analog Input then you need to set the ADCON1 reg. as follow: ADCON1 = 0x04; then here u can go with the TRISx in the chip above PORTA pins by default configureg as analog input. please refer to the DATA sheet of the chip and especially to the associated reg(s). with each I/O PORT. that was I know ...I hope it will help. Regards Mohammed ----- Original Message ----- From: "Ed Troy" To: Sent: Monday, August 06, 2001 1:40 PM Subject: [PIC}: Incredibly simple program works in simulator but not on board!! > In an effort to try to debug the program that I am having trouble with, I > have stripped it down to the very basic essentials. It is now a program > that should toggle some bits on and off depending on the value of bit RA4. > If RA4 is high, RD7 and RD6 should toggle from high to low. If RA4 is low, > then RD5 should toggle from high to low. (I know I typed RD5 in twice, but > that should not make any difference.) The program works fine in the > simulator (and I also know that the actual delay is a lot less than 1 > millisecond...I just wanted to simplify the simulation). But, when I go to > the actual board, everything just sits at zero!! The clock signals look > fine, and the supply voltages are fine. I've tried several chips, so it is > not a bad chip. I've tried turning on and off the power up timer, and I've > turned off the watchdog timer. I've also turned off the brownout timer. > Usually, I have the master clear tied directly to the power supply, but > I've also tried tying it to 5 volts after the power supply is up and > running. Nothing seems to matter. The really strange thing is that the > simulation works fine, and I get no errors or warnings when I compile. I'm > obviously doing something VERY wrong, but I don't know what it is. > > Ed > /* > > This is the suspect c file > > */ > > #include > #include > > void DelayMs(unsigned int cnt) > { > unsigned i; > i=6; > while(i!=0) > i--; > while(cnt!=0) > cnt--; > } > > > void Initialize_Ports() > { > TRISB=0x00; // set port b as outputs > TRISD=0x00 ; // set port d as output > TRISA=0x3F ; // set port a as inputs > TRISC=0x00 ; // set port c as output > PORTD=0x00 ; // initialize port D to zero > PORTC=0x00 ; // initialize port C to zero > } > > > main() > { > Initialize_Ports(); > RD3=1; > RD2=1; > RC6=1; > DelayMs(2) ; > RD4=1; > RD2=0; > RC7=1; > while(1) // loop forever > { > RC6=1; > DelayMs(2) ; > if (RA4 = 1) > { > RD7=1; > RD6=1; > DelayMs(1); > RD7=0; > RD6=0; > } > else > { > RD5=1; > RD5=1; > DelayMs(1); > RD5=0; > RD5=0; > } > > } > > } > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics