PDA

View Full Version : how to use 12F509



marad73
- 30th April 2006, 20:18
Hi, I have a Picstart + and am using CDLite. (runs great, by the way!) The information in the PBP manual, as well as John Iovine's book is very scanty about how to use the IO on the chip.
Questions:
1. Do I call the IO "GPIO" or something else? I have tried PORTA.X and GPIO.X and both assemble ok. However, I can't get any output or input from the chip in its application.
The MPLab assembler seems to work ok but calls programming a "failure".
2. Can I use the 12C509 firmware code in Picstart + with a 12F509?
3 Does anyone have some sample code that works well with 12F509 and PBP?
4. Do I need to set up the oscillator differently? (from internal similar to 12C509)
Would appreciate any help I can get, since I am fairly new at this!
Thanks,
Ron

mister_e
- 30th April 2006, 21:49
I don't us CDLite and it's no longer supported by Melabs so may i suggest you to use MicroCode Studio instead?
Download it here (http://www.rentron.com/mcstudio/mcs2300.zip)

Or you can still use MPLAB and do everything in. For that you'll need to install the PicBasic plug-in
MPLAB installation page (http://melabs.com/support/mplab.htm)

Now you may need to upgrade your PICSTART firmware and MPLAB to the latest version
MPLAB download page (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002)

Once it's done, you should'nt have any other compilation or you still have an older PBP version wich doesn't support the 12F509 like Version 2.44 and those before. If so, you'll need an update of it too.

Once everything above is done, you should be able to do something workable.

When you want to access to an i/o, you must call the proper PIC register as stated in the PIC datasheet, in your case GPIO.

to set the internal oscillator and all config fuses.. read the following link
http://www.picbasic.co.uk/forum/showthread.php?t=543

a sample code... well let's try something using MPASM config fuses... oh no i never use the PM compiler, sorry.



'
' Pic Configuration
' =================
@ __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC ' Disable MCLR pin
' Disable code protection
' Disable Watch-Dog timer
' Use internal OSC

'
' Hardware configuration
' ======================
TRISIO=0 ' Set almost i/o to output
'
' Software/Hardware initialisation
' ================================
GPIO = 0 ' Clear almost i/o
'
' ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' Program Start Here
' ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
' Nothing fancy, just do a blink on almost i/o
'
Start:
GPIO=GPIO ^ $FF
pause 500
goto start


Why i said 'almost i/o'? it's up to you to discover now :)