Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic16f628a not working

Status
Not open for further replies.

4848

Newbie level 3
Joined
Jun 2, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,330
please help me out, i program pic16f628a with JDM2 programmer using Winpic8000 with my Laptop serial port. after the programm was sucessfull i put it into a circuit but it did not work. i try to reprogram it with anothe code i downloaded from the internet that is design for pic16f628a, but it does not work also. i re-programme it, it we be programm sucessfull, but yet it does not work please what should i do. the code i write to test the pic is
;testing programm for pic
#include "p16F628A.inc"
; CONFIG
; __config 0xFF38
__CONFIG _FOSC_INTOSCIO & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _CP_OFF
org 0
goto Start
Start
bsf STATUS,RP0
clrf TRISB
clrf TRISA
bcf STATUS,RP0
movlw B'10101010'
movwf PORTB
movwf PORTA
Loop
nop
goto Loop
;
end


The other code i download is

MPASM Tutorial - LED Flash

LIST p=16F628A ;tell assembler what micro is in use
include "P16F628A.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the config settings (oscillator type etc)

cblock 0x20 ;start of general purpose registers
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc

LED Equ 0 ;set constant LED = 0
LEDPORT Equ PORTA ;set constant LEDPORT = 'PORTA'

org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off

bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PORTB all outputs
movwf TRISB
movwf TRISA ;set PORTA all outputs
bcf STATUS, RP0 ;select bank 0
clrf PORTA
clrf PORTB ;set all outputs low

Loop
bsf LEDPORT, LED ;turn on RA0 only
movlw d'250' ;delay 250 ms
call DelayMs ;this waits for a while
bcf LEDPORT, LED ;turn off RA0 only
movlw d'250' ;delay 250 ms
call DelayMs
goto Loop ;go back and do it again

DelayMs movwf count1 ;Move delay count to "count1"
d1 movlw 0xC7 ;delay 1mS
movwf counta
movlw 0x01
movwf countb

Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0
decfsz count1 ,f
goto d1
retlw 0x00

end

But yet it does not work, what went wrong
 

Hi,

Your code looks ok, though PortA may not work properly as you have not turned off the comparators by adding these lines as shown in your second example.
Code:
movlw 0x07
movwf CMCON ;turn comparators off

Your Example has Mclre ON whereas the second code has Mclre OFF.
Because your first example is Mclre ON you must have a pull up resistor to VDD of around 10k on Mclre Pin1 or the chip will not run.

If the second example does not work then I think you may have another problem.

Would suggest you put your chip back in the programmer, lets say you have already programmed it with your first code.
Now just READ the chip and see if the screen buffer is filled with hex code - yes or no ?
If no then the chip did not program properly.

If yes, then load your compiled program code into the buffer and select VERIFY to see if the buffer and chip agree yes or no ?
IF no , then you seem to have a burning problem

If yes, then it seems you might have a problem on your hardware circuit.,so attach at diagram if you can so we can see what you have built.


Edit - have just simulated both those code examples and they work fine, so it must be your hardware circuit or programmer.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top