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.

GPR problem with 16f877

Status
Not open for further replies.

kvrajasekar

New Member
Hi,

I am using 16f877(asm code).my project required 150 registers to store some data.I have used bank0,1,2 to declare registers.But when i used bank0 and bank1 simultaneously my loop is getting hang.

Please help me...here is my code..

copy_limits routine is there in page 2.to access it i used fcall.but when the control enters into copy_thu..it gets hanging.
 

Attachments

  • rtc_test_working.asm
    5.4 KB · Views: 161
There is a lot of code missing in what you posted. We can't guess what

Code:
		goto	copy_sun
does when there is no "copy_sun" marker.

As a start, you are using a lot of bankselects that aren't needed.

Code:
	cblock		0xa0

st_thu_min1
st_thu_hr1

.........

clear_thu
		banksel	st_thu_min1
		clrf	st_thu_min1
		banksel	st_thu_hr1
		clrf	st_thu_hr1

You don't need to select banks when you are already in that bank.

You are using the wrong tool for the job. The 16F877 is a pain for stuff like that. There is no good way to transfer a block of data, as there is only one indirect addressing register.

If you use a PIC18F4420, you can access 196 registers directly, without having to change banks. It is just about pin compatible with the 16F877

If you want to transfer a block of data, you can write:-

Code:
	lfsr	fsr0, source
	lfsr	fsr1, destination
	movlw	data_size
	movwf	count
transfer_loop
	movff	postinc0, postinc1
	decfsz	count, f
	bra		transfer_loop
 
You are using the wrong tool for the job. The 16F877 is a pain for stuff like that. There is no good way to transfer a block of data, as there is only one indirect addressing register.

If you use a PIC18F4420, you can access 196 registers directly, without having to change banks. It is just about pin compatible with the 16F877

If you want to transfer a block of data, you can write:-

Code:
         lfsr    fsr0, source
         lfsr    fsr1, destination
         movlw   data_size
         movwf   count
transfer_loop
         movff   postinc0, postinc1
         decfsz  count, f
         bra     transfer_loop

It's only slightly more difficult to copy blocks of memory on the 16F' devices. Here's a method I use from PICLIST;

Code:
        movlw   d'16'           ; record byte count               |B0
Data_Copy
        movwf   Count           ; save count                      |B0
        addlw   Source-1        ; source buffer address           |B0
        movwf   FSR             ; setup source indirect           |B0
        movf    INDF,W          ; get data byte                   |B0
        movwf   Temp            ; save it                         |B0
        movlw   Target-Source   ; add buffer span                 |B0
        addwf   FSR,F           ; setup target indirect           |B0
        movf    Temp,W          ; retrieve data                   |B0
        movwf   INDF            ; copy into DBLOCK                |B0
        decfsz  Count,W         ; all bytes copied?               |B0
        goto    Data_Copy       ; no, branch, else                |B0

The OP's choice of device family is not the problem. It's his program organization.

Mike
 
Status
Not open for further replies.

Latest threads

Back
Top