View Full Version : GP2 on a 10F202 as output
mat janssen
- 6th January 2007, 19:43
I read the whole datasheet of the 10F202 and I did not succeed in finding how to set GP2 as an output.
When I put a led via a resistor at GP0, GP1 and GP2 only the GP0 and GP1 leds are working the led on GP2 remains off. (not broken).
See small example.
What do I forget ??
'test voor 10f202
@ DEVICE PIC10F202,INTRC_OSC
@ DEVICE PIC10F202,MCLR_OFF
@ DEVICE PIC10F202,PROTECT_OFF
@ DEVICE PIC10F202,WDT_OFF
DEFINE OSC 4
TRISIO = %00000000
OSCCAL.0 = 0
UIT1 VAR GPIO.0
UIT2 VAR GPIO.1
UIT3 VAR GPIO.2
IN1 VAR GPIO.3
BEGIN:
IF IN1 = 0 Then
UIT1 = 0
UIT2 = 1
UIT3 = 0
EndIF
IF IN1 = 1 Then
UIT1 = 1
UIT2 = 0
UIT3 = 1
EndIF
GoTo BEGIN
skimask
- 6th January 2007, 20:47
I read the whole datasheet of the 10F202 and I did not succeed in finding how to set GP2 as an output.
When I put a led via a resistor at GP0, GP1 and GP2 only the GP0 and GP1 leds are working the led on GP2 remains off. (not broken).
See small example.
What do I forget ??
'test voor 10f202
@ DEVICE PIC10F202,INTRC_OSC
@ DEVICE PIC10F202,MCLR_OFF
@ DEVICE PIC10F202,PROTECT_OFF
@ DEVICE PIC10F202,WDT_OFF
DEFINE OSC 4
TRISIO = %00000000
OSCCAL.0 = 0
UIT1 VAR GPIO.0 : UIT2 VAR GPIO.1 : UIT3 VAR GPIO.2 : IN1 VAR GPIO.3
BEGIN:
IF IN1 = 0 Then
UIT1 = 0:UIT2 = 1:UIT3 = 0
EndIF
IF IN1 = 1 Then
UIT1 = 1:UIT2 = 0:UIT3 = 1
EndIF
GoTo BEGIN
10F202 datasheet (DS41239A)....page 21 (Section 4.6) and page 37 (Section 8.0) will give you all the answers you need.
mister_e
- 7th January 2007, 11:42
i'll bet on
OPTION_REG.5=0
mat janssen
- 7th January 2007, 12:03
@ Skimask:
I read that part. Thats why I put in the programm :OSCCAL.0 = 0
@ Mister_e:
You win the price. That helped.
I read also that the option reg bit 5 should be 0 , but I wrote at that time in my programm OPTION.5 = 0 , and the compile gave me an error. I forgot to type it in the correct way.
Thanks.
Regards
Mat
mister_e
- 7th January 2007, 12:11
yup OPTION.5 won't work unless you decide to redefine it
@OPTION=OPTION_REG
OPTION VAR BYTE EXT
' or the simple one
OPTION VAR OPTION_REG
Doesn't help if you don't know OPTION_REG ;)
In this case you could still open the filename.ASM file, there you'll have...
R0 EQU RAM_START + 000h
R1 EQU RAM_START + 002h
R2 EQU RAM_START + 004h
FLAGS EQU RAM_START + 006h
R4 EQU RAM_START + 007h
R3 EQU RAM_START + 008h
GOP EQU RAM_START + 00Ah
OPTION_REG EQU RAM_START + 00Bh
RM1 EQU RAM_START + 00Ch
RR1 EQU RAM_START + 00Dh
SOFT_STACK_PTR EQU RAM_START + 00Eh
TRISIO EQU RAM_START + 00Fh
SOFT_STACK EQU RAM_START + 010h
mat janssen
- 7th January 2007, 12:23
I know, but still !!
Powered by vBulletin™ Version 4.0.3 Copyright © 2010 vBulletin Solutions, Inc. All rights reserved.