PDA

View Full Version : Setting I/O ports on 16f629



Optech
- 24th January 2008, 19:04
I have been programming a 16f876 for various control/signal generation applications for years using the TRISA=? line to set the ports to input or output.
I was hoping to use a smaller (8 pin) chip such as 16F629 to generate a asymmetrical squarewave to regulate a clock but the datasheet is set out very differently to the 876.
Does anyone know if I can use similar code to set the ports, and if not how is it done?
thanks.

peterdeco1
- 24th January 2008, 19:27
Hi Optech. The command you're looking for is TRISIO. Use it just as you would TRISA. The 1's are inputs, 0's are outputs.

CMCON = 7 'comparators off
trisio = %11111111 'set all as inputs
DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device

skimask
- 24th January 2008, 19:28
I have been programming a 16f876 for various control/signal generation applications for years using the TRISA=? line to set the ports to input or output.
I was hoping to use a smaller (8 pin) chip such as 16F629 to generate a asymmetrical squarewave to regulate a clock but the datasheet is set out very differently to the 876.
Does anyone know if I can use similar code to set the ports, and if not how is it done?
thanks.

16F629?
Maybe a 12F629...
Yes, they are practically the same, but different.
The PBP manual explains the difference between Ports and GPIO's, TRISIO, etc.

Optech
- 24th January 2008, 21:51
Thanks for the info. I have now found the relevant section in the pbp manual although it refers to the 12f675. Also skimask, you were right it is 12f629 - just a typo - or brainfade - not quite sure which...