Microcontroller › PIC › Help regarding writing hex file to PIC12F675
- This topic has 2 replies, 3 voices, and was last updated 7 years, 7 months ago by Ashutosh Bhatt.
-
AuthorPosts
-
January 18, 2017 at 4:54 pm #4601RobosapienParticipant
I'm new to programming pic chips and I recently bought a pickit 2 clone to learn PIC microcontroller programming.
I also downloaded the Pickit 2 software Application version 2.61.00, Device File version 1.61.00 and OS Firmware Version 2.32.00.
The software seems to be working fine as I've noticed that it can detect whether the programmer is connected or not. and also, it detected my pic chip properly. Hence I'm sure the hardware connections are proper.
I'm using a PIC12F675 8 pin microcontroller and am coding in assembly as it is easier for me to estimate the timings for the events required in my project.
The Pickit 2 application has a window titled 'Program Memory' wherein i can see the hex values of the asm code in my hex file.
When i select my hex file to be uploaded to the microcontroller, the 'Program Memory' window gets updated with the hex codes in the hex file. When i click on the button 'Write', the message window turns green and says 'Programming Sucessful'.
But when i click on the Button that says 'Read', the message window turns green and says it finished reading and the all the values in the program window turns to zero (0000).
The problem i am facing is that I am implementing a customised blink LED code but the LEDs in the circuit are not glowing, so I'm not sure if the program got uploaded properly.
I have attached the asm code and the circuit diagram I'm using for my project.
#include p12f675.inc
__CONFIG _FOSC_INTRCIO & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _BOREN_ON & _CP_ON & _CPD_ON
RES_VECT CODE 0x0000 ; processor reset vector
GOTO START ; go to beginning of program
MAIN_PROG CODE ; let linker place main programSTART
banksel TRISIO
clrf TRISIO ;tris10
clrf INTCON ;intcon
clrf IOC ;ioc
clrf ANSEL ;ansel
movlw B'11011111'
movwf OPTION_REG
banksel GPIO
movwf GPIO
banksel GPIO
comf GPIO
movlw H'20'
movwf H'0020'
decfsz H'0020'
goto $+2
goto $-6
movlw H'20'
movwf H'0021'
decfsz H'0021'
goto $+2
goto $-7
movlw H'20'
movwf H'0022'
decfsz H'0022'
goto $-1
goto $-7
ENDBasically, my idea is to have all the GPIO pins toggle after a specified time interval.
And here is my the circuit diagram I'm using.I've connected 2 LEDs in series to reduce the voltage on each LED. 3V is the rated Voltage for a single LED, but it glows just a little dim when supplied 2.5V directly. But when connected in this circuit, it dosent glow at all. I tried powering the LEDs from pin 6, 7 and 3 but none of them make the LEDs glow.
So, where am i going wrong? is my code improper? or is any configuration bit setup improperly or is the code not getting uploaded?
Thanks in advance.
January 19, 2017 at 8:37 am #14350GANEEV SINGHParticipantHi there
I am not sure about PIC microcontrollers but I will suggest you to try out this code on a simulator like Proteus or something similar. It will help you detect problem in code, in any.
Such simulators are really helpful if you want to debug something or if want to see how your project works.
You will get Proteus software online easily.
January 25, 2017 at 7:09 pm #14371Ashutosh BhattParticipantno one uses assembly language now a day
just switch over to embedded C language
-
AuthorPosts
- You must be logged in to reply to this topic.