Quick one about the 16f675

Status
Not open for further replies.

2camjohn

Member
Im using GPIO 4 and 5 to drive a tri colour LED.

The problem is GPIO 5 never goes high, it hovers around 0.1V.

Port 5 is declared as an output and im setting it high but its not turning the LED on.

GPIO 4 works fine.

I know its not my circuit because when I short pin 5 high using a peice of wire, the LED comes on.

From reading the datasheet there doesnt seem to be anything special about port 5.

My chip must be broken ?? Right??
 
It's a 12F675, 16F675 doesnt exist.

GPIO5 can also be used as crystal osc - CLKIN.
Are you sure you have your configuration word correct ?

It can also be T1CKI - Timer 1 clock input - Make sure T1CKI is turned off...

Aside from that, maybe you made a little error wich u cannot spot - Post your code.
 

I presume you mean the 12F675?.

GP5 can be set as:

General purpose I/O.
TMR1 clock input.
A crystal/resonator connection.
A clock input.

It's possible the chip could have been damaged?, but more likely you've got it set wrong somewhere - particularly check your config fuses, in case you've got it set wrong there.
 
Thanks for the help so far guys.

Yeah I mean the 12F675.








The chip is configured in winpicprog to use the inti oscillator.

The config word is $01C4


I have removed everything from the code except turning on the LED.

Here is the code
Code:
ANSEL = %00110001
ADCON0 = %10000001

T1CON.TMR1CS = 0
T1CON.TMR1ON = 0





'Inputs and Outputs
'------------------
TRISIO.0 = 0
TRISIO.1 = 0
TRISIO.2 = 0
TRISIO.3 = 1			'Not Connected
TRISIO.4 = 0			'LED Green Output
TRISIO.5 = 0			'LED Red Output

Symbol led_red = GPIO.5
Symbol led_green = GPIO.4

CMCON.2 = 1				'This disables the comparator
CMCON.1 = 1				
CMCON.0 = 1	




'turn led orange
High led_red
High led_green

The LED comes on green instead of orange, gpio 4 reads just under 5V, gpio 5 reads 0.1V.

The code is in BASIC but i think its pretty easy to read for anyone who knows about PICS.

Thanks for all the help so far...
 
Code:
High led_red
High led_green

Try instead :

Code:
High led_green
High led_red

If you reverse the last 2 lines do you get a red LED?

(I'm trying to figure out what High does precisely, might be your problem)
 

Nope

But if I reverse the LED I get a red LED




High just sets that output high. Ive used it countless times over the last 18 months without any problems until now.
 
Ok, just wanted to make sure "High" did not overwrite the whole port instead of just one bit.

Is that source file big? The problem might be somewhere else, because what you posted looks good, as far as I can tell. Can you post more?
 
Have you tried to read TRISIO.5 after you've assigned it 0 to make sure it is indeed 0?

Maybe also try to disable the comparators before you set TRISIO...


Code:
ANSEL = %00110001
ADCON0 = %10000001

T1CON.TMR1CS = 0
T1CON.TMR1ON = 0

CMCON.2 = 1            'This disables the comparator
CMCON.1 = 1            
CMCON.0 = 1  

'Inputs and Outputs
'------------------
TRISIO.0 = 0
TRISIO.1 = 0
TRISIO.2 = 0
TRISIO.3 = 1         'Not Connected
TRISIO.4 = 0         'LED Green Output
TRISIO.5 = 0         'LED Red Output

Symbol led_red = GPIO.5
Symbol led_green = GPIO.4

' No clue if I am using the right If syntax here, just guessing
If TRISIO.5 = 0
    'turn led orange
    High led_red
    High led_green
End If

So if TRISIO.5 is 0, you should at least get a green LED, but if TRISIO.5 is wrong, the LED won't light.
 
OK I have tried that and GPIO.5 is set to 0

Code:
ANSEL = %00110001
ADCON0 = %10000001


T1CON.TMR1CS = 0
T1CON.TMR1ON = 0

CMCON.2 = 1				'This disables the comparator
CMCON.1 = 1				
CMCON.0 = 1	



'Inputs and Outputs
'------------------
TRISIO.0 = 0
TRISIO.1 = 0
TRISIO.2 = 0
TRISIO.3 = 1			'Not Connected
TRISIO.4 = 0			'LED Green Output
TRISIO.5 = 0			'LED Red Output

Symbol led_red = GPIO.5
Symbol led_green = GPIO.4


'set the outputs low just in case
Low led_red
Low led_green




If TRISIO.5 = 0 Then 'if trisio.5 is 0 (output), turn led orange
	'turn led orange
	High led_red
	High led_green
Endif

Unfortunately it still gives me a green LED.
 
It was a broken chip after all.


I have just salvaged another 675 from an old project and I have my orange light 8)


Looks like for the first time ever it wasnt my fault (well, I broke the chip, but the problem in this case wasnt down to my dodgy software/hardware).
Looks like I might be turning a corner


Thanks for the help everyone, very informative as always.


John
 
I've been playing with PICs for only two months and already have 3 broken chips to my record. Sh*t happens!

Glad it's working, I could have lost sleep over this :roll:
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…