Hi Guys,
I am a new member of GCB Community. I am writing a code for AVR but i am stuck into a situation. My requierment is to set a pin to its default state (not 1 or not Zero). Please tell me how can i do this. I Could not find any command of GCB for this purpose.
Thanks
Last edit: Kaka 2015-05-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am not sure that there is such a command.
I would look at the data sheet for the device to see what the pin defaults to on reset and then just set the output accordingly. You might wish to define a constant for this state. eg
define Pin1Default 0.
Then you just use
set PortA.1 Pin1Default
or whatever is appropriate for the port/pin in question.
Most pins on micros default to inputs also (check the data sheet again).
Peter.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Have a look at the demonstration folder within your installation. Then, the LED example folder. This folder has many examples on how to turn a port (with an LED attached).
The summary is:
~~~~
chip, (chip type)
'set direction of the port. I have used porta.1 in this example
dir porta.1
do forever
set porta.1 on
wait 1 s
set port1.off
wait 1 s
Loop
Last edit: Anobium 2015-05-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As you said you want it "not 1 and not zero" you need to set the pin as an input.
DIR porta.0 in
will do this (for porta pin 0) puts the pin effectively into open circuit state.
Pins are generally tristate either 0,1 or floating.
DIR porta.0 out
set porta.0 on 'puts pin zero
set porta.0 off ' puts pin at one
dir porta.0 in ' puts pin open circuit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Guys,
I am a new member of GCB Community. I am writing a code for AVR but i am stuck into a situation. My requierment is to set a pin to its default state (not 1 or not Zero). Please tell me how can i do this. I Could not find any command of GCB for this purpose.
Thanks
Last edit: Kaka 2015-05-06
I am not sure that there is such a command.
I would look at the data sheet for the device to see what the pin defaults to on reset and then just set the output accordingly. You might wish to define a constant for this state. eg
define Pin1Default 0.
Then you just use
set PortA.1 Pin1Default
or whatever is appropriate for the port/pin in question.
Most pins on micros default to inputs also (check the data sheet again).
Peter.
Welcome.
Have a look at the demonstration folder within your installation. Then, the LED example folder. This folder has many examples on how to turn a port (with an LED attached).
The summary is:
~~~~
chip, (chip type)
'set direction of the port. I have used porta.1 in this example
dir porta.1
do forever
Loop
Last edit: Anobium 2015-05-06
As you said you want it "not 1 and not zero" you need to set the pin as an input.
DIR porta.0 in
will do this (for porta pin 0) puts the pin effectively into open circuit state.
Pins are generally tristate either 0,1 or floating.
DIR porta.0 out
set porta.0 on 'puts pin zero
set porta.0 off ' puts pin at one
dir porta.0 in ' puts pin open circuit
I believe that David has it correct.
A tri-state Pin by definition has three states:
ON (High)
OFF (Low)
Floating (Indeterminate/High Impedance) or Input
If we assume that the default power up state is floating and the Pin has been made an output, then to return to the default state the code would be:
Good, You guys are great. following script works fine for me.