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! code for pic16f676 is not working

Status
Not open for further replies.

s.shirse

New Member
hi friends!
just now i started coding on pic16f676. below code is written for toggling port with delay. this code is not working when i burn it into ic. it's working on simulator.


__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

ORG 00
GOTO START

ORG 0x04
RETFIE

ORG 0x50
START NOP
BANKSEL TRISC
CLRW
MOVWF TRISC
MOVWF ANSEL

MOVLW 0xFC
MOVWF OSCCAL
BANKSEL PORTC
BCF INTCON,GIE
MOVLW 0x15
MOVWF PORTC

HERE1 COMF PORTC,F
CALL RDELAY
HERE GOTO HERE1

RDELAY MOVLW 0x05
MOVWF 0x31
MOVLW 0x0FF
MOVWF 0x32
MOVWF 0x33
B1_RDELAY DECFSZ 0x33,F
GOTO B1_RDELAY
DECFSZ 0x32,F
GOTO B1_RDELAY
DECFSZ 0x31,F
GOTO B1_RDELAY
RETURN

END
 
Hi,

Your code seems fine, would suspect either you have not got Mclre pulled up by a 10k resistor CONFIG MCLRE_ON or your outputs, if using leds, are not wired correctly.

Strongly recommend you assign Labels to your User Registers rather than addressing them directly as 0x32 etc. - your will code will soon become very confusing doing it that way.
 
Remove these and see if it works
MOVLW 0xFC
MOVWF OSCCAL

Some of your instrucitons are unnecessary:

MOVLW 0x15
MOVWF PORTC

MOVLW 0x0FF
MOVWF 0x32
MOVWF 0x33
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top