Why PORTA work?... O.K Let's open and look one section of the PBPPIC14.lib file located in the PBP folder.
Code:
.......
;****************************************************************
;* Fake PORT settings for 12C67x, 14C000 *
;****************************************************************
ifndef PORTA
PORTA EQU 5
endif
........
AND now if we open the 12F675 datasheet section 2.2.2 and we look the figure 2-2 on the left colums, we discover that GPIO is located @ 05H.... In the above snip, they create an alias to GPIO.
The usual way to write a program, is to use the correct name of the port... wich, in your case, is GPIO. your code will look like
Code:
GPIO = 2
Pause 400
GPIO = 4
Pause 400
--------------------------------------------------------------------------
I have defined pin 0 as input and pin 1 and 2 as outputs.
Input PORTA.0
Output PORTA.1
Output PORTA.2
It's one way to do it. You use the PBP function. You can also use the TRISIO register to do that... look section 3.0. your code will look
Code:
TRISIO.0=1 ' GPIO.0 As input
TRISIO.1=0 ' GPIO.1 As output
TRISIO.2=0 ' GPIO.2 As output
OR in one line
Code:
TRISIO=%111001 ' GPIO<2:1> as output, all the other as input
--------------------------------------------------------------------------
Can you please explain that about disableing analogue functions on multiplexed pins?
Look in section 6 and section 7. you'll discover the setting to use in CMCON and ANSEL register.
CMCON=%00000111
ANSEL=0
Now go in the FAQ and read the following thread wich discuss on HOW TO SET the PIC configuration fuses => http://www.picbasic.co.uk/forum/showthread.php?t=543
Do a search in this forum with 12F675 and you'll probably found some good example.
A really simple example here.
Code:
'
' Hardware configuration
' ======================
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
' Internal Oscillator
' Disable watch dog timer
' Enable power up timer
' Disable MCLR function but leave this pin available as input
' Enable brown out detect
CMCON = %00000111 ' Disable analog comparator
ANSEL = 0 ' Disable A/D converter
TRISIO = %111001 ' Set GPIO<2:1> as output, the other as input
'
' Hardware connection
' ===================
SWITCH VAR GPIO.0
LED1 VAR GPIO.1
LED2 var GPIO.2
'
' ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
' Program Start Here
'
' ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
START:
IF SWITCH=1 THEN
LED1=1
LED2=0
ELSE
LED2=1
LED1=0
ENDIF
GOTO START
Bookmarks