Data direction 18 pin.

picnut

New Member
Is there any reason why data direction cannot be changed on any PORTB pin by using TRISB ?. I would like to reconfigure for four digital inputs and four digital outputs,

Thank you ....

picnut
 

hippy

Ex-Staff (retired)
Welcome to the PICAXE forum.

The PICAXE was designed for its primary target audience and not as a general purpose PICmicro so this was a design decision. On the PICAXE 18X it is possible to gain some control over the output pins and make them inputs by poking SFR used by the firmware but this is not recommended nor supported and care has to be taken as PORTB defaults to outputs after power-on and reset.
 

picnut

New Member
Thank you very much for the explanation. Could you please confirm that the closest I can get to what I need is the 28x2 ?. Thank you ...

picnut
 

hippy

Ex-Staff (retired)
It depends on exactly what you need and what other I/O you require. The 14M and upwards can support 4 inputs, 4 outputs, and the 14M has a configurable PORTC ( more details in Appendix C of PICAXE Manual 1 ). If you are after a single byte-wide port which can be input and output and defaults to input, the 28X1 or 40X1 will fit the bill (PORTC), as will the 28X2 and 40X2 ( pinouts also in Manual 1 ).
 

Janne

Senior Member
Hi all,

Again, search found just about what i needed. However, one thing is baffling me a little bit. I read the pic16F88 datasheet for picaxe 18x, and for the portb direction there are two databytes in trisb, $86, and $186. Can anyone tell me, why there are 2 of these control bytes in the sfr? TRISA makes more sense, as there is only 1 byte for the direction of the pins.

As for why i need to poke the direction registers, I want to connect 2 leds on the picaxe output legs, red and a green one. By poking the output legs as inputs, i can neatly disable both leds by making the leg high impedance imput =)
 

hippy

Ex-Staff (retired)
The two SFR registers for PORTB in a PICmicro are the same register but placed in different register banks to aid PICmicro programming.
 

Janne

Senior Member
Thanks for the replies.

Jurjen,

Your post has pretty much covered the whole issue, so thanks for that. Don't know how I managed to miss that one :)
 

westaust55

Moderator
Hi all,

Again, search found just about what i needed. However, one thing is baffling me a little bit. I read the pic16F88 datasheet for picaxe 18x, and for the portb direction there are two databytes in trisb, $86, and $186. Can anyone tell me, why there are 2 of these control bytes in the sfr? TRISA makes more sense, as there is only 1 byte for the direction of the pins.
I do not have a firm and definitive answer but both serve the same purpose.

There are several other SFR’s in the same position having two registers for the same purposes (ie $06 and $106, .also $81 and $181).

They are in different SFR banks so presumably the TRISB direction control is provided in each bank by Microchip to minimize SRF bank switching.

This is somewhat irrelevant to the PICAXE as the PICAXE chip can only access the first two banks thus TRISB SFR at $86 is accessible, but not $186 located in SRF bank 3.
 
Top