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.

MPLAB IDE, using MPLABSIM and programming a 12F509.

Status
Not open for further replies.

T1959

New Member
I am new to programming and have run into a problem which I hope this forum can help with.

My goal is to write a program for the 12F509 that generates a pulse 7 times per second, simple. The pulses go to an interface which drives a stepper motor. The only twist is that I want the ability to adjust the delay time between each pulse via two switches and I want indicator LEDs to confirm the press of a button and to indicate that the pulses are at max or min rates. To get this done I have two switches and three LEDs connected to the 12F509.

The problem I would like to receive comment on relates to the use of the simulator in MPLAB. I have noticed that when I launch the debugger and animate the program the simulator crashes after a time, which never seem to be the same. The question is do I need to configure the simulator in a particular way for use with the 12F509?

Also, I am using the PICKIT2, purchased from Microchip. For some reason MPLAB has started not erasing the chip but states that it did. The interface which came with the programmer does erase the chip. I have tried to erase from MPLAB with and without the PICKIT2 interface active and the results are the same. This problem started when I reconfigured the location of the switches.

Comments, thank you, attached is the code.
 

Attachments

  • complete code.ASM
    5.6 KB · Views: 222
Solved

THe simulator problem is not solved but the issues with the Pickit2 seem to be solved by using a differnt PC.

Thanks.
 
You are going to get into a lot of trouble doing this:
bsf GPIO,4
bcf GPIO,1
bcf GPIO,2
The chip will simply not respond.
It is best to work out the final state you need and load the GPIO.

decfsz env_delay
should be: decfsz env_delay,1

incf ns_c
should be: incf ns_c,1
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top