PDA

View Full Version : pic12F683 , gpio.5 not accessible...



flipper_md
- 24th April 2008, 02:05
Hello all

I've got my project quickly up n running thanks to Darrel's Instant Interrupts, but now I would like to use all pins on the 12F683 and my GPIO is just the most useless i've ever seen!!


-I've try two different chip, same result
-hack of options and settings, nothing, niet, nada

ANSEL = %00000000 ' No Analog input, set all digital
CMCON0 = %00000111 ' turn comparators off 07H
TRISIO = %011100 ' inputs, outputs
GPIO = %000000 ' outputs low << very important it seems!!
OSCCON = %01110000 ' Internal 8MHz osc set speed


I just want to use it as a button, or serial out, but no can do so far, it gives zEro volts, and react to nothing as a digital pin...unless I got a stupid mistake in my settings.

others GPIO works fine (0to4), i get my serialLCD going no prob on GPIO.1


thnx for help.


So here is some more of the code, in case youd see the obvious bug:

include "DT_INTS-14.bas" ;' DT Instant interrupt routines
include "Elapsed_INT.bas" ;' Timer routines


include "ReEnterPBP" ;' code is begin me to add this...

Include "modedefs.bas" ' Serial port routines

define OSC 8

; settings in INC file
' set in INC file => device pic12F683, intrc_osc_noclkout, wdt_off, mclr_off, protect_off ; FOR INSTANT INTERRUPT

INTCON = 0 'Do not use PBP interrupts

ANSEL = %00000000 ' No Analog input, set all digital
CMCON0 = %00000111 ' turn comparators off 07H
TRISIO = %011100 ' inputs, outputs
GPIO = %100000 ' outputs low << very important it seems!!
OSCCON = %01110000 ' Internal 8MHz osc set speed


' ******** Instant Interrupt setup ***************************
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _DetectSendLaps, PBP, yes
INT_Handler TMR1_INT, _ClockCount, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor

INT_ENABLE INT_INT ; enable external (INT) interrupts
INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
ENDASM

; OPTION_REG = OPTION_REG & $80 | 1 ; Set TMR0 Prescaler to 256, leave RBPU alone, adjust for Xtal freqz

LED1 VAR GPIO.0
LCDport VAR GPIO.5 'LCD*communication port

Output GPIO.0
Output GPIO.1
Input GPIO.2
Input GPIO.3
Input GPIO.4
Output GPIO.5

pause 1200 'let the LCD boot

'Custom character for LCD
'Empty heart
serout LCDport, N9600, [18, 64, $0A, $15, $11, $0A, $04, $00, $00, $00 ]
'Filled heart
serout LCDport, N9600, [18, 72, $0A, $1F, $1F, $0E, $04, $00, $00, $00 ]

serout LCDport, N9600, [ 12 ]
serout LCDport, N9600, [ 12 ]

mackrackit
- 24th April 2008, 02:49
GPIO = %000000 ' outputs low << very important it seems!!

I just want to use it as a button, or serial out, but no can do so far, it gives zEro volts, and react to nothing as a digital pin...unless I got a stupid mistake in my settings.
Try setting as an input.

GPIO = %000001

flipper_md
- 24th April 2008, 04:00
well, I went aroudn trying pretty much every combination possible...

TRISIO = %101100
GPIO = %100001

TRISIO = %101100
GPIO = %000001

TRISIO = %001100
GPIO = %000001

TRISIO = %101100
GPIO = %000000

there's just no way to turn on a LEd on that GPIO.5

reading the spec sheet, it's a TLL cmos like all other ports... I can't see the missing link :<


any working code that use that port as digital IO?


tnx Dave for the quick reply

Archangel
- 24th April 2008, 06:27
flipper_md
>>well, I went around trying pretty much every combination possible...

TRISIO = %101100 <font color=red>= Ports 2,3,5 AS INPUTS 0,1,4 as outputs</font color>
GPIO = %100001 GPIO sets ports high or low if outputs, not if inputs. . . .

TRISIO = %101100
GPIO = %000001

TRISIO = %001100 Here port.5 is an output, 2-3 as inputs
GPIO = %000001 Port zero is output high

TRISIO = %101100
GPIO = %000000

there's just no way to turn on a LEd on that GPIO.5

reading the spec sheet, it's a TLL cmos like all other ports... I can't see the missing link :<


any working code that use that port as digital IO?

http://ww1.microchip.com/downloads/en/DeviceDoc/41211C.pdf

Darrel Taylor
- 24th April 2008, 06:48
; settings in INC file
' set in INC file => device pic12F683, intrc_osc_noclkout, wdt_off, mclr_off, protect_off ; FOR INSTANT INTERRUPT

If you're using Instant Interrupts, the program has to be assembled with MPASM.

Look at the __CONFIG line in the 12F683.inc file, not the device line.
<br>

Archangel
- 24th April 2008, 07:25
If you're using Instant Interrupts, the program has to be assembled with MPASM.

<br>

Hi Darrel,
I thought he was as he did not report any compiler errors, doesn't PM choke on DT_I.I.?

Darrel Taylor
- 24th April 2008, 07:48
Yes, PM will definately "choke" on Instant Interrupts.

What I'm saying is that ... since it appears he's using MPASM, he's looking at the wrong configs.
<br>

flipper_md
- 24th April 2008, 08:32
ohh you got a point here!

Modified the __config line and it's definitely using it...

__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF

but then I get
ICDWarn0033: MPLAB ICD 2 does not support programming this device if both the internal oscillator and internal MCLR are selected. You may continue programming, but you are encouraged to cancel, reconfigure your device, and try again.
ICD0200: Operation Aborted (Warning 32).

so basically I assume I cannot have all pins as digital IO.

still It's better for me to set MCLRE on and get GPIO.4/5 working, and leave MCLRE pin alone.
Unless there's a way to bypass this...

It's also great to know which compiler i"m using :) LOL

edit: setting MCLRE_ON I can get access to GPIO 4 and 5 now..
Still I wonder if it's possible to get rid of MCLR

Darrel Taylor
- 24th April 2008, 11:48
Hmmm, It must be a limitation of your programmer.

I just tested it here with a 12F683 and an meLabs U2 programmer.
It works fine with the internal oscillator and MCLR either ON or OFF.
<br>

flipper_md
- 24th April 2008, 17:27
humm, it means ICD2 (clone) is less powerfull/featured than yours...
would never expected that!

or maybe I can try to let it program the chip anyways, and see what happen.

i'll try it tonight.


Thanks for testing

mister_e
- 24th April 2008, 19:47
Maybe be not less powerful... but has it's own way to work. ICD2 is more a debugger than a programmer. Melabs's one is a Programmer, period.

Cheap alternative.. the endless Microchip's PICKIT 2 suggestion.... which can also be used as a debugger on some PIC.

sayzer
- 28th April 2008, 10:44
Flipper,

How did you set your OSC to work internally at 8Mhz?


OSCCON = %01110000 ' Internal 8MHz osc set speed

I think, it should be OSCCON = %01110001

Did you notice that?

========================

mister_e
- 28th April 2008, 17:25
My 2 cents. From the datasheet

bit 0 SCS: System Clock Select bit
1 = Internal oscillator is used for system clock
0 = Clock source defined by FOSC<2:0> of the Configuration Word register

I don't feel this is the problem here, unless the config fuses aren't properly set. Default ones use the internal osc so far.

flipper_md
- 29th April 2008, 01:47
Ohh, umm, I took the speed value from another source code but I didnt double checked it...
good point that I should verify those kind of things!

All seems to run fine tough. It ran datatransfert at 19200baud using serout2, no prob.

And since I was sad about loosing a pin for a totally useless MCLR, my brain got spinning and I decided to try using one pin as A/D to read integer values of voltage(1to5). Then I will hook a 4-way switch with matching resistors and I'll get 4-5 *inputs* from that pin. uhuhuh.
I hope nothing come in my way this time...im so proud of this Einstein spark!!



Thanks Mister_E for enlightening my little knowledge of programmers.
I taught they were pretty much all equal, but now I see why mine was sold for cheap ;)

but for now, my skills surely wouldn't make use of a 300$ programmer.

and I still have to try to overide the warning and see what happen!! 8)

Jumper
- 29th April 2008, 02:38
http://forum.microchip.com/tm.aspx?m=8106&mpage=1&key=internal%2cMCLRᾬ
http://forum.microchip.com/tm.aspx?m=204180&mpage=1&key=internal%2cMCLR&#204739


this might explain why.... but as they say. If you power your PIC from the ICD2 and don't load it too much it might work anyway. And to get rid of this warning just use an older version on MPLAB.

/me

flipper_md
- 29th April 2008, 03:22
uhh, so steppin back in old version of MPlab would make it work fine... funny ;)

thanks for digging that out!

flipper_md
- 9th May 2008, 05:25
Well, I have tried both MPlab 7.40 and 7.20 , and still get the warning 33 about using both Osc/master clr internal

The chip seems to take some hit when trying to force programming.
I have to erase it a couple times when I see a verify error, then it seems to work ok :O

So I assume I have to let go one pin away...


But now I got and little funny part to play with! Heart rate monitor chip strait from the maker, Polar. Got to find how to use the signal :P