Aug 28, 2003 #1 S SadE Newbie level 4 Joined May 26, 2003 Messages 5 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 73 Hi , I'm testing Hitech C with this little sample program that normally toggle A0 & A1 ... But PORTA never blinks ... When I look at the asm code , the XOR is well generated !!! Coud you explain me why it doesn't work please ? #include <pic.h> #define XTAL_FREQ 20MHZ __CONFIG(WDTDIS & HS & PWRTDIS & BORDIS); main(void) { unsigned int i; PORTA=0x03; TRISA=0x00; for(; { for (i=0;i<1000;i++); PORTA^=0x03; } }
Hi , I'm testing Hitech C with this little sample program that normally toggle A0 & A1 ... But PORTA never blinks ... When I look at the asm code , the XOR is well generated !!! Coud you explain me why it doesn't work please ? #include <pic.h> #define XTAL_FREQ 20MHZ __CONFIG(WDTDIS & HS & PWRTDIS & BORDIS); main(void) { unsigned int i; PORTA=0x03; TRISA=0x00; for(; { for (i=0;i<1000;i++); PORTA^=0x03; } }
Aug 28, 2003 #2 T TheHungry Full Member level 2 Joined Mar 6, 2002 Messages 147 Helped 4 Reputation 8 Reaction score 2 Trophy points 1,298 Activity points 999 main(void) { unsigned int i; PORTA=0x03; TRISA=0x00; while(1) { for (i=0;i<1000;i++); PORTA^=0x03; } }
main(void) { unsigned int i; PORTA=0x03; TRISA=0x00; while(1) { for (i=0;i<1000;i++); PORTA^=0x03; } }
Aug 28, 2003 #3 T TheHungry Full Member level 2 Joined Mar 6, 2002 Messages 147 Helped 4 Reputation 8 Reaction score 2 Trophy points 1,298 Activity points 999 main(void) { unsigned int i; PORTA=0x03; TRISA=0x00; for(; { for (i=0;i<1000;i++); PORTA^=0x03; } }
Aug 28, 2003 #4 S SadE Newbie level 4 Joined May 26, 2003 Messages 5 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 73 after some investigation I found that the the same code work on PORTB and not on PORTA, even in asm !!! PORTA=0x00; TRISA=0x00; PORTB=0x00; TRISB=0x00; for(; { for (i=0;i<1000;i++); asm("MOVLW 01"); asm("XORWF 05,F"); asm("MOVLW 01"); asm("XORWF 06,F"); }
after some investigation I found that the the same code work on PORTB and not on PORTA, even in asm !!! PORTA=0x00; TRISA=0x00; PORTB=0x00; TRISB=0x00; for(; { for (i=0;i<1000;i++); asm("MOVLW 01"); asm("XORWF 05,F"); asm("MOVLW 01"); asm("XORWF 06,F"); }
Aug 28, 2003 #5 picman2 Member level 2 Joined May 18, 2001 Messages 51 Helped 2 Reputation 4 Reaction score 0 Trophy points 1,286 Activity points 363 It seems you forgot to disable some analog features on your chip ! Read carefully the default state of I/O pins on datasheet, then initialize correctly them ! Cheers PicMan
It seems you forgot to disable some analog features on your chip ! Read carefully the default state of I/O pins on datasheet, then initialize correctly them ! Cheers PicMan
Aug 28, 2003 #6 C C-Man Advanced Member level 4 Joined Jul 19, 2001 Messages 1,059 Helped 90 Reputation 180 Reaction score 17 Trophy points 1,318 Activity points 10,189 Which cpu are you useing? 16F877 and 16F627 / 628 switch PORTA to analogue mode on reset, you have to switch to digital mode if you want to use PORTA as output ... hope this helps
Which cpu are you useing? 16F877 and 16F627 / 628 switch PORTA to analogue mode on reset, you have to switch to digital mode if you want to use PORTA as output ... hope this helps
Aug 28, 2003 #7 S SadE Newbie level 4 Joined May 26, 2003 Messages 5 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 73 Yeahh you're right ! I have switched off the A/D but it seems you have to set the INTCON1 right . It's funny that only the XOR operator doen't work when portA pins are in analog mode. AND and OR are working ! thx
Yeahh you're right ! I have switched off the A/D but it seems you have to set the INTCON1 right . It's funny that only the XOR operator doen't work when portA pins are in analog mode. AND and OR are working ! thx