Joined: 08 Apr 2008 19:30 Posts: 48 Location: United States
i am using mikroC 220.127.116.11 to program PIC16F84A, it works just fine when i use the built-in libraries, but when i access the individual bits, it starts to function incorrectly, the code below should make RB3 OUT and RA2 IN, and when a "1" is applied on RA2, RB3 should blink, but it doesnot, instead it blinks when i apply the 5V to the PIC, i.e. it doesnot care whether a 1 is applied to PORTA or not, can any one tell me why?
TRISB.f3=0;// make RB3 out
TRISA.f2=1;// make RA2 in
the code shown above works just fine when i replace
TRISB.f3=0 with TRISB=0;
TRISA.f2=1 with TRISA=0
Did you make sure you have pulldowns enabled on PORTA (on the develeopment board), and the jumper for the keypad is set to pullup (VCC)? Otherwise your input is floating when you don't press a key and results will be unpredictable. That could explain what you see.
No sure why you set PORTA to zero - after all you only use it as an input.
I notice if portB.f1 initiall happens to be 1 and you don't press a key, it will stay on forever. I'd suggest adding an else clause to your code that turns it off when your input isn't high.
That special, some time ago I have also problem with individual bit access. I do a program working fine on a PIC16F887 accessing the bit individualy but when I try to adjust and work on a PIC 16F877A then I had to work also with the full PORT... I don't really know how work PORTx.Fx... maybe somebody have the ansewr...
Is it possible to work in microC with seperate c and h files, coz i would like to put the interrupt routine in a seperate file in the project and place further ISR routines that i call from the interrupt() functions also in seperate modules (c files), so modulair and structured programming.
How can i do that without having to deal with compile time errors when i start the main() method.
Now i'm doing the following with my project:
bodeplotter.c (main program)
int_handler.c (onlyl interrupt() ) with call from the ISR functions
adc_isr.c (all functions that deal with adc)
How can i resolve that and If possible with a example.
I was wondering, what if a pin is the input and output? Can you make it so that when u declare TRISx that one of the pin is don't care? I probably can do this by declaring TRISx.0 to TRISx.7 as the input or output and just ignore the pin that is both. What is the don't care symbol?
Users browsing this forum: No registered users and 0 guests
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 post attachments in this forum