View previous topic :: View next topic |
Author |
Message |
RatherBeFlying
Joined: 14 Jul 2004 Posts: 11
|
PIC10F202 Pull-up & Wake on Pin Change |
Posted: Fri Jun 02, 2006 3:41 am |
|
|
Hi,
I feel the answer is simple, but somehow can�t figure it out!
The datasheet for PIC10F202 does not show the OPTION register address so I can�t use the #byte to access the register bits. Then how to enable weak pull up on input pins and also how to enable wake up from sleep on pin change (from pull up to ground)? I need to enable both at the same time for all input pins.
The CCS project wizard does generate the C source to use the built in command port_b_pullups (TRUE); but it shows Undefined identifier error on this command when compiling.
Also, the datasheet shows that the OPTIONS register (with N/A address) revert back to default settings on Reset (which is disable weak pull ups and wake from sleep on pin change)? Does this mean that when the PIC wakes up is actually reset rather than continuing to the next line after Sleep?
Thanx for any help.
Sorry, i forgot to metion that i am using version 3.236 |
|
|
Ttelmah Guest
|
|
Posted: Fri Jun 02, 2006 4:48 am |
|
|
If you look at the manual for 'port_b_pullups', you will see an entry, where it says "For PCM & PCH only, for PCB, use 'setup_counters'". Now the reason for this is hardware. On the 'PCB' chips (10, and 12), the pullups are controlled by a bit in the option register, and this is accessed by the 'setup couners' command.
If you use:
setup_counters(RTCC_INTERNAL,0);
The pullups will be enabled. Substitute the required prescaler etc., for the first value. If you want the counters disabled, substitute 'DISABLE_PULLUPS' for the second value.
If you look at the listing generated by this command, you will see it performs the 'option' command.
Best Wishes |
|
|
RatherBeFlying
Joined: 14 Jul 2004 Posts: 11
|
|
Posted: Fri Jun 02, 2006 12:18 pm |
|
|
Thanx Ttelmah, we live and learn.
So if i need wake up on pin change as well then another setup counter call should be made?
What do you think if i just use the following just before entering the while(1) loop and change the byte value in W to be the entire OPTION register setting?
Code: |
#asm
MOVELW 0
OPTION
#endasm
|
Thanx again. |
|
|
RatherBeFlying
Joined: 14 Jul 2004 Posts: 11
|
|
Posted: Sat Jun 03, 2006 11:45 am |
|
|
Anyone successfully compiled PIC10F20x on CCS?
Strange problems occurring, with a search on the forum, a Configuration word problem could still be the issue as in:
http://www.ccsinfo.com/forum/viewtopic.php?t=22709
The end of my Hex file is
:060120004604800A030002
:021FFE00EB0FE7
:00000001FF
;PIC10F202
Shouldn�t that be 07FE as explain in the thread?
Thanx. |
|
|
|