PDA

View Full Version : making ports outputs on a 12F629



bartman
- 12th November 2004, 05:38
I don't think this is a required command since I am only using HIGH and LOW on the ports which I understand automatically set the port to input or output, but that doesn't stop me from wanting to understand doing this better.

If I look at the chip data sheet I see that the gpio register starts at 5h and the trisio starts at 85h. <b>Physical</b> pins are as such:

1 - +5v
2 - port 5 I/O
3 - port 4 I/O
4 - port 3 / MCLR
5 - port 2 I/O
6 - port 1 I/O
7 - port 0 I/O
8 - ground

So, I want to make ports 0,1,2,4 and 5 as outputs, port 3 either as MCLR or not used at all. Pins 1 and 8 obviously serve there own purpose. Here is a graphic of the registers:

http://www.t2.net/users/bartman/remotelink/chart.gif

I believe I should be able to use POKE $85, <b>?</b> to set the I/O to output on the pins I need, but at the same time not interfere with the other ports. In my mind, since I want all but the MCLR to be outputs it would look like: <b>POKE $85,%0001000</b> or even <b>POKE $85,%00000000</b> since some are ignored and setting pin 3 to MCLR=ON in my programmer it will select the proper bit on it's own.

Am I somewhat close on my logic? Using the PBC manual this seems reasonable.

Thanks.

Bart

Melanie
- 14th November 2004, 15:03
Poke $85,%00001000 is the way to go, which is equivallent to TRISIO=%00001000. You will also have to set CMCON to disable the comparators and ANSEL to disable the ADC's (where appropriate).

bartman
- 14th November 2004, 18:47
I used <b>Poke $85,%00000000</b> and it seemed to work. I didn't use <b>Poke $85,%00001000</b> because I wasn't sure if I considered voltage at MCLR an "input" so to speak and because the data sheet seemed to indicate setting MCLR poked that value properly itself. I'll have to go back and read it again.

I did also figured out to use the poke command for the comparitor to turn it off and this chip doesn't have ADC so I didn't worry about that. It is still somwhat foggy on it all since usually only some of the 8 bits are used for any one register and I've been assuming to just fill the rest with 0. So far so good. No smoke anyway.

Bart