PDA

View Full Version : Pic10f206



mdown
- 18th December 2007, 03:43
I am trying to get the simple program below running.

<code>
PIN0 VAR GPIO.0

start:
HIGH PIN0
PAUSE 500
LOW PIN0
PAUSE 500
GOTO Start
</code>

I am using PBP v2.47 / vMCS 3.0.0.5 / MPASM v5.14
This is the first time I have really used PBP. Although I have used ZBasic for years.

I have the MELabs Serial Programmer and can compile and flash the code ok, but when power is applied to the proper pins the pic does nothing.

Thanks,

Mike

mister_e
- 18th December 2007, 04:06
Hi and welcome on the forum,

regardless to their size... they all have a datasheet, and few things have to be checked first. Here you want to use a specific I/O as a digital signal... but...
http://www.mister-e.org/Pics/woohoo
This specific i/o have some analog stuff multiplexed on, so you MUST check if it's enable at POR.. unless... yes it will never ever dare to work... just to ruine your whole life and loose some hair at same time. So let's open the datasheet together
http://ww1.microchip.com/downloads/en/DeviceDoc/41239D.pdf

Page 3, table 1-1, it says it has 1 comparator, page 4, pin diagram show GP0/ICSPDAT/CIN+ the comparator input. Let's scroll to page 39, Register 8-1 CMCON0 register. At power up, it show comcon0=%11111111.. BIT3 CMPON.. when = 1 comparator is on.... you don't want it. clear everything

CMCON0=0

this should cure the problem.

PS: default setting says that MCLRE is enabled, make sure you tie MCLR pin to vdd, or change the configuration fuse to disable the MCLR feature.

more info
http://www.picbasic.co.uk/forum/showthread.php?t=543

mdown
- 18th December 2007, 15:34
Thanks for the help. I figured it was something silly like that. I got the fuses figured out and GP3 now functions as an input like I want it to. However the GP2 pin is set by several registers. We disabled CMCON0 so that takes care of COUT, but leaves T0CKI, FOSC4 is set to 0 in the OSCAL0 register so that should be ok. So if I am correct I need to get T0CS=0. Yes?

Thanks again,

Mike

mister_e
- 18th December 2007, 15:40
Yes yes yes :D

mdown
- 18th December 2007, 15:51
Here is what I am trying do really do with this device:


<code>

@ __config _MCLRE_OFF & _WDT_ON & _CP_OFF

Include "modedefs.bas"

CMCON0=0

SI var GPIO.0 'Define serial in pin
WakePin var GPIO.1 'Define Wake Pin
B0 var byte

start:
low wakepin 'Set the WakePin low
serin SI,N9600,10,start,b0 'Wait for an interval
high wakepin 'Set the WakePin High, we got our interval
B0 = B0 * 60 'Convert the interval to seconds
sleep b0 'Sleep for the interval specified
goto start 'Go to "Start"
</code>

mister_e
- 18th December 2007, 16:02
Bear in mind it's a real nifty PIC, i'll suggest you to use DEBUGIN instead of SERIN. At least @9600 baud with internal OSC, better the chances are to work with DEBUG than SERIN. There's a warning about that in the manual.

I never tried DEBUGIN/SERIN with 10F though...

mdown
- 28th December 2007, 02:45
So I have been trying to get T0CS=0 in the OPTION register but PBP doesn't seem to under stand "OPTION" as a register name.

Any ideas?

paul borgmeier
- 28th December 2007, 04:28
try OPTION_REG instead of OPTION