Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

12F675 output problems

Status
Not open for further replies.

Jerran

New Member
Any input would be appreciated. Im playing around with a transmitter/reciever module. To use it I have to set 4 bits parellel then bring the transmit enable pin low. The problem Im having is I cant set 2 pins to output at the same time for some reason.

Ive tried 2 test programs to see what was going on under the hood. I put leds on gpio 0 and 1 then tried the following code with the transmit enable tied to ground.

main:
gpio = 3
pause 2000
gpio = 0
pause 2000
goto main

which produced nothing. I then tried manually setting each pin via...

main:
high gpio.0
high gpio.1
high gpio.2
pause 2000
low gpio.0
low gpio.1
low gpio.2
pause 2000
goto main

and only gpio2 toggles. Does anyone see my flaw?
 
Ive been flipping threw the data sheets and I thing the problem is from pins 0 and 1 being configured as comparator inputs. Now I just need to figure out how to trun the bloody thing off ;)
 
I tried disabling the comparitor and analog inputs but am still getting the same problem. My code works fine on a 16F84A so I know its gotta be in the config of the 12F675.

ADCON0.0 = 0
ANSEL.0 = 0
ANSEL.1 = 0
ANSEL.2 = 0
ANSEL.3 = 0
vrcon.7 = 0
 
Jerran said:
I tried disabling the comparitor and analog inputs but am still getting the same problem. My code works fine on a 16F84A so I know its gotta be in the config of the 12F675.

ADCON0.0 = 0
ANSEL.0 = 0
ANSEL.1 = 0
ANSEL.2 = 0
ANSEL.3 = 0
vrcon.7 = 0

You don't seem to be setting CMCON anywhere, this is what sets the pins as comparators. This initialisation code is taken from the datasheet.

Code:
bcf STATUS,RP0 ;Bank 0
clrf GPIO ;Init GPIO
movlw 07h ;Set GP<2:0> to
movwf CMCON ;digital IO
bsf STATUS,RP0 ;Bank 1
clrf ANSEL ;Digital I/O
movlw 0Ch ;Set GP<3:2> as inputs
movwf TRISIO ;and set GP<5:4,1:0> ;as outputs
 
Cool thanks Nigel, I thought the vrcon command disabled it but it just disables the voltage reference.
 
Take a look in the datasheet. The GPIO.3 on 12F675 is input only. I think it has to do with that it is the MCLRE pin (which has to be disabled).
 
Ya gpio.3 is input only. I assigned gpio to 3 (gpio = 3) to make pins 0 and 1 HIGH. I cut and pasted the ansel commands from a previous project and probably should have removed ansel.3 = 0 from my post.

Thanks for the replies all.

(edited for bad spelling. I lay blame on my slow coffee maker lol)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top