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.

Help programing a 12C508

Status
Not open for further replies.

ywat

New Member
Hello,
i need a little help to program a 12C508. I think my request will be easy for anyone here knowing how to program a PIC.
On power, if pin 4 (GP3) is grounded, pin 2 will send VCC (pin 1 value) and pin 3 will be grounded (VSS value, pin 8) as long as the pic is powered, if pin 4 is not connected to ground pin 2 will send ground and pin 3 VCC (invert value).
The state is validate on power on only, and no change can be made. I want to use it with a analog switch. 3 USB input, one output. This little code will help me to test other case.
Thank you very much for your help !
 
This is where I wish they filled in their location.... They may not be able to get the newer chips...

I always which they had, as so many questions are location specific - however, it's hard to imagine a country where you can't get other than antique chips like the 12C508 :D

It makes it VERY, VERY expensive if you're going to use OTP chips, buying UV erasable versions and an eraser for development.
 
Thank you for your answers !
12C508 may be a poor choice, but i know this one will do the job.
If you can advise me on which one i can use to do what i want for cheaper and smaller to program, i will do with it.
Programming an Urduino is very noob friendly, but for the PIC, it's not the same stuff... i can try, but the OTP version will cost a lot for the little things i want to do...
I prefer using a erasable Chip, i only have a K150 programmer bought on ebay a long time ago.
I think i can handle the programming of a chip. I live in France, getting another one is fine i think... and ebay is here to help.

The tutorial 2 seems to be OK. I just have to deal with it and remove the loop i think (retlw). If i can use a erasable PIC i will prefer it.
 
Last edited:
Listed at MicroChip as new releases are the 8 pin 12F1571, 12F1572 and 12F1612.

But why not just use the 12F508?, the re-programmable replacement for the 12C508.
 
dude, you save my day. the 12F508 is compatible with my K150 programmer.
i will try to do what i want by myself, and will come back to you, if i may, if anything is wrong.
thank you for all !
 
i have ordered the erasable pic, i have now to wait.
can you tell me if that kind of code can work ?
i will only use 2 input and 2 output for this test. if it's ok (or not), please tell me.
Code:
start
   movlw b'001110'        ; GP4 GP5 GP0 are output, other are pressbutton
   tris GPIO

   btfsc GPIO,2
   btfss GPIO,3
   movlw b'010000'        ; set GP4 high on GP3 low only
   movwf GPIO
   retlw 0

   btfss GPIO,2
   btfsc GPIO,3
   movlw b'100000'        ; set GP5 high on GP2 low only
   movwf GPIO
   retlw 0

   btfss GPIO,2
   btfss GPIO,3
   movlw b'110000'        ; set GP4 GP5 high when GP2 and GP3 are pushed to gnd
   movwf GPIO
   retlw 0

   movlw b'000000'        ; else set none
   movwf GPIO
   retlw 0

   END

I dont need a loop or a goto. the state of each output is initialize on power up. if pressbutton is removed after, the output stay as it is.
Thank you !
 
I was wondering what the naked RETLW's did, so I simulated it:

upload_2014-11-4_6-16-24.png


Using the MPLAB template, it simply returns to the ORG (i.e., movwf OSCAL).

Is there more to the program that hasn't been posted?

John
 
I understand BCF and BSF as status set or clear. set as active low. clear when not plugged anywhere.
the main program is posted. retlw 0 was return, but i saw on a forum that return command isnt understood by a 12F508...
if the return instruction means "you can stop here, the condition is valid" so lets use return !
maybe a switch case condition will be easier to read...
 
if the return instruction means "you can stop here, the condition is valid" so lets use return !
maybe a switch case condition will be easier to read...

No! it forces a reboot.... A return without a call causes a stack underflow... to stop forever use


stop: goto stop

or just

goto $

Simple...
 
roger that.
so
Code:
   btfss GPIO,2
   btfss GPIO,3
   movlw b'110000'        ; set GP4 GP5 high when GP2 and GP3 are pushed to gnd
   movwf GPIO
   goto $
is valid to you and fulfill my initial request ??? after goto $, if i release GP2 and/or GP3, GP4 and GP5 will stay high ?
thank you, i'm noob on assembly code...
 
Last edited:
The thing is, after the first block of code, there is no way to progress past that return. So, the rest of your code might as well not exist. "goto $" will not do what I think you want it to do. The $ stands for the current program counter position. In other words, your code will halt or time out.

Although retlw is always used after something like a "call," except in your code, it does function by returning to the top of the "stack," as shown in the simulation. MPLAB SIM is free, included in Microchip's software package, and is simple to use for the 12F508 chips. You can step through your code one step at a time and see what the program does using a "watch" window.

I suggest you try it.

John
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top