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.

Pic16f877a

Status
Not open for further replies.

Nanya

New Member
Hi Guys,

I am working with the PIC16F877A and I am having problems with my 4secs and 1 secs delay code I wrote in assembly. It does not seem to work. Please can someone suggest a better way because I am not so enlightened about this kind of MC.
tHANKS,
Nanya
 
Use a stopwatch!!

Seriously, how do you expect anyone to help when you supply no details whatsoever. How about you post your code.

Mike.
 
I ma sorry. Here is the code (This is just part of the code that contains the details of the delay section):

;TELEPHONE EXCHANGE.ASM
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;EQUATES SECTION

LIST P=16F877A
#include "P16F877A.INC"
_CONFIG_CP_OFF_WDT_OFF_PWRTE_ON_XT_OSC
CBLOCK 0X0C
ENDC
ORG 0X00
GOTO BEGIN
ORG 0X04
GOTO BEGIN
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;SUBROUTINE SECTION

;4 SECONDS DELAY
DELAY4 CLRF COUNT1
DELAY4A MOVLW .200
MOVWF COUNT1
DELAY4B DECFSZ COUNT1
GOTO DELAY4B
DECFSZ COUNT2
GOTO DELAY4A
RETLW 0
;1 SECOND DELAY
DELAY1 CLRF COUNT1
DELAY1A MOVLW B'01100100'
MOVWF COUNT1
DELAY1B DECFSZ COUNT1
GOTO DELAY1B
DECFSZ COUNT3
GOTO DELAY1A
RETLW 0
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;CONFIGURATION SECTION

BEGIN MOVLW .78
MOVWF COUNT2
MOVLW .39
MOVWF COUNT3

CLRF PORTB
CLRF PORTC
CLRF PORTD
CLRF REGCONNECT
BSF STATUS,5
BCF STATUS,6
MOVLW B'11111111'
MOVWF TRISA

MOVLW B'00000000'
MOVWF TRISB

MOVLW B'00000000'
MOVWF TRISC

MOVLW B'11111111'
MOVWF TRISD

MOVLW B'00000111'
MOVWF OPTION_REG

MOVLW B'00000110'
MOVWF ADCON1

BSF STATUS,6
BCF EECON1,7
BCF STATUS,5
BCF STATUS,6

I do not know how to attach the whole code file to the message.

THanks,
Nanya
 
You should take a look at the . This will get you working 1 and 4 second delay routines.

Mike.
 
Thank you. I went to the link and generated the code but can u pls expali what this line of code means:

goto $+1


nanya
 
The $ sign is equal to the program counter and so goto $+1 = goto the next line. It is only inserted to waste 2 cycles. Earlier in the code there is goto $+2 which skips the next line.

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top