...Headahce with the PIC12F683!

Thread Starter

assembler_C

Joined Mar 19, 2008
7
Hi...

I'm new here... My name is Normand Martel, i live in Montreal, Québec and have been made a lot of assembler and C programming in the past.

My headache has started with the PIC12F683. (I've made a lot of programming on the 18 pinners without any hassle)

I've taken a very well functioning assembler code from a PIC16F648 to adapt it to the 12F683 and everything has crashed!

I've written a (simpler) code to let you see my problem....

Please see "test_683.txt" attached file to see my code.

; Simple test program to try to get around my (CENSORED) GPIO/int problem.
; This simple program generates low frequency squarewavec on pin 7
; My problem: I CANNOT DO ANYTHING WITH THE GP2/INT INPUT!!!
; I've made A LOT of assembler on PIC16F84 and 16F628 without any
; hassles! But, i do not know what's around the 12F683, but nothing works!!!!

; This sample program is simply a programmable delay (with 8 different delay length values
; depending of the "tonalite" variable turning round and round,
; toggling GP0 everytime. also, pin 3 (GP4) is supposed to follow pin 5 (GP2)
;The "tonalite" variable is SUPPOSED to increment at each interruption (GP2/INT)
 

Attachments

n9352527

Joined Oct 14, 2005
1,198
You need to configure the pins to digital I/O. The pins are multiplexed with analogue inputs and comparator. Usually the default setting, on power-up, the pins are configured as analogue inputs. See the datasheet on how to do it, look for something with Digital I/O, ANSEL and CMCON registers.
 

Thread Starter

assembler_C

Joined Mar 19, 2008
7
Thanks a lot!!!!

The right answer was with the ANSEL register. By clearing the four lower bits, (ANS3-ANS0), pins 3, 5, 6 and 7 respectively, are assigned to digital I/O's. These four bits are SET on POR and therefore corresponding pins are assigned as ANALOG.

ANSEL's address is 0x009F. As with TRISIO (0x0085), it must be configured in BANK 1.
 

n9352527

Joined Oct 14, 2005
1,198
You're welcome. I'm glad you've solved the problem.

This is one of the most common pitfalls in PIC. There have been several posts in this forum from users experiencing the same problem. It would be a lot more logical, at least for me, for Microchip to set the default pins configuration on POR to digital I/O. They must have a strong reason not to do so.
 
Top