Society of Robots - Robot Forum
Software => Software => Topic started by: aruna1 on October 10, 2008, 09:50:23 PM
-
Guys i read this tutorial ( http://www.societyofrobots.com/member_tutorials/node/161 (http://www.societyofrobots.com/member_tutorials/node/161) ) about tri state switch.according to it in order to brake the motor i have to convert a output pin to a input pin.example i use A0 as an output and when i want to brake the motor i have to write a code to make A0, a input pin.I don't know how to this.Any help would be great.Hope you understand what I'm saying.(I use CCS C for programming and using PIC16F877A so please post relevant C code for this) ???
thanks :)
-
I don't know about CCS C, but if you look in the tutorial in my signature, you can see a macro called FLIP_PORT that does toggling, it can be used for either high/low or input/output
-
I don't know about CCS C, but if you look in the tutorial in my signature, you can see a macro called FLIP_PORT that does toggling, it can be used for either high/low or input/output
thanks i'll check
-
On an ATMEL/AVR chip you use the Data Direction Register to control whether a pin is an output pin or an input pin. Not sure what the equivalent is with a PIC but after a quick look at the datasheet then assuming you are using PORTA then the equivalent direction port is TRISA where a 0=output and 1=input. So if you are using PORT A pin 2 then:
TRISA |= (1<<2) ; will make PORTA pin2 an input
TRISA &= ~(1<<2); will make PORTA pin2 an output
This is only a guess - as I dont have any PIC experience.
-
On an ATMEL/AVR chip you use the Data Direction Register to control whether a pin is an output pin or an input pin. Not sure what the equivalent is with a PIC but after a quick look at the datasheet then assuming you are using PORTA then the equivalent direction port is TRISA where a 0=output and 1=input. So if you are using PORT A pin 2 then:
TRISA |= (1<<2) ; will make PORTA pin2 an input
TRISA &= ~(1<<2); will make PORTA pin2 an output
This is only a guess - as I dont have any PIC experience.
i didn't get it it. if TRISA means port A how to define port a pin 1 and pin 2(or any other pin)?
-
Check the tutorial in my signature :P