Status
Not open for further replies.

#### prean

##### New Member
hey guys, does anyone know how to mask an 1byte to 512 bytes in assembly? or is it even possible? or would it be better to mask 256bytes to 512 bytes? oh its for the PIC16f690

thanx

#### blueroomelectronics

##### Well-Known Member
Huh? What are you trying to do?

##### Banned
Masking omits certain parts of a given byte, it doesn't increase the byte count, your post makes no sense.

#### prean

##### New Member
ok how can i increase the byte count? i wana increase the data byte size to 512bytes so i can write the data to sd-card

#### Gayan Soyza

##### Active Member
You place two 8bit registers & name them "Lower byte" & "upper byte"
If you want to increment the current number just increment the "lower byte".If it exceeding 255! increment the "upper byte" by 1.

#### prean

##### New Member
im sorry but i dont understand. im new to assembly language

#### Gayan Soyza

##### Active Member
Just think of two 8 bit registers. If you like name them as “upper byte” & “lower byte”.
Just think they don’t have any values, both are zeros.

Now you increment the “lower byte” now it contains “1”.Now again increment it, now it contains “2” likewise if you increment 255 times the “lower byte” contains “255” if you increment at this stage its value becomes “00” because the maximum value that an 8 bit register can hold is 255.At this stage you need to increment the “upper byte” by one. Because your value is 256.

So for every 256 times the “upper byte” increment by one.

If you have “1” in the “upper byte” & “00” in the “lower byte” then the whole 16bit pair contains 256 value.
If you have “2” in the “upper byte” & “00” in the “lower byte” then the whole 16bit pair contains 512 value.

Do you understand how these number system works?

#### prean

##### New Member
ok i understand what u saying there. see what im trying to do is basically transfer data from the PIC16F690 to an sd card.we jus writing to the card,not reading.but the data comes in at 1Byte at a time.and the sd card writes in 512bytes. i can store all the values in the data eeprom of the PIC16F690 and when it reaches 256bytes, increase to 512 bytes and the write to the card. do you maybe have any ideas about this? or any codes that i use? thank u so much for your help. much appreciated. i wrote out a code jus to see how the eeprom on the PIC works. jus a basic counter problem. i got sum advise from someone on the forum who edited my code. however after loading the edited code onto the pic, it outputs the orginal loaded data,and does not increment by itself like a counter sholud do.

#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)

cblock 0x70
DATA_EE_DATA
dly0
dly1
W_DATA
R_DATA
endc

org 0
nop

;; intialise output ports
banksel ANSEL
movlw 0x00
movwf ANSEL
banksel ANSELH
movlw 0x00
movwf ANSELH
banksel TRISC
movlw 0x00
movwf TRISC
;; movlw 0xF0
;; movwf DATA_EE_DATA
;; movlw 0x00

; To WRITE into EEPROM
movlw 0x03 ; Writes Hous data into EEPROM
movwf W_DATA ; Data to be written
call EE_WR ; Write routine for EE_Addr

movwf R_DATA ; Write into Hyst High register

; -------------------------------------------------------------------------------------------------
;EE_WR EEPROM DATA WRITE SEQUENCE
; -------------------------------------------------------------------------------------------------
EE_WR
banksel EECON1 ; Select Bank of EECON1
btfsc EECON1,WR ; Wait for write
goto $-1 ; to complete banksel EE_ADR ; movf EE_ADR,W ; banksel EEADR ; (0x10C) Select Bank of EEADR movwf EEADR ; Data Memory Address to write banksel W_DATA ; movf W_DATA,W ; Register containing data to be stored banksel EEDATA ; (0x10D) movwf EEDATA ; Data Memory Value to write bsf STATUS,RP0 ; bcf EECON1,EEPGD ; Point to DATA memory bsf EECON1,WREN ; Enable writes bcf INTCON,GIE ; Disable INTs. movlw H'55' ; movwf EECON2 ; (0x18C) Write 55h movlw H'AA' ; movwf EECON2 ; (0x18C) Write AAh bsf EECON1,WR ; Set WR bit to begin write bsf INTCON,GIE ; Enable INTs. bcf EECON1,WREN ; Disable writes banksel PIR2 ; btfss PIR2,EEIF ; Wait for interrupt flag to be set goto$-1 ; Current line -1
bcf PIR2,EEIF ; Clear the EEWRITE interrupt flag

; -------------------------------------------------------------------------------------------------
; EE_RD EEPROM DATA READ SEQUENCE ;
; -------------------------------------------------------------------------------------------------
EE_RD ;
banksel EECON1 ;
bcf EECON1,EEPGD ; Point to Data memory
banksel EEDATA ;
movf EEDATA,W ; W = EEDATA
banksel R_DATA ;
movwf R_DATA ; Move W into EE_BYTE
movf R_DATA,W
banksel PORTC
movwf PORTC
return ; Value now in W, to be used

; -------------------------------------------------------------------------------------------------
; WRITE routine to write data ;
; into EEPROM memory Hours ;
; -------------------------------------------------------------------------------------------------
WriteEE: ;
movwf W_DATA ; Writes Hous data into EEPROM
call EE_WR ; Write routine for EE_Addr

end

#### Gayan Soyza

##### Active Member
Try this it reads the first 256 locations in the EEPROM.

Code:
Main		movlw 	0x00 		; EE pointer

movf 	R_DATA,W	;
movwf	PORTC		;
call	Delay		;call a 1Sec delay
Wait_Here	goto	Wait_Here

EE_RD ;
banksel EECON1 		;
bcf 	EECON1,EEPGD 	; Point to Data memory
banksel EEDATA 		;
movf 	EEDATA,W 	; W = EEDATA
banksel R_DATA 		;
movwf 	R_DATA 		; Move W into R_DATA
return

Last edited:

#### SPDCHK

##### Member
Gayan, I see with the poster you are going to have to spoon feed him all the way. I was the one who helped him out on the EE_Read and EE_Write code. I did not modify his code, I gave him a copy of my code that does work. As for incrementing or whatever else he wants to do, he'll have to write the code himself.

I see you have a "Call Delay" instruction in there. He's going to mail you back now and complain that it doesn’t work.

#### Gayan Soyza

##### Active Member
Gayan, I see with the poster you are going to have to spoon feed him all the way. I was the one who helped him out on the EE_Read and EE_Write code. I did not modify his code, I gave him a copy of my code that does work. As for incrementing or whatever else he wants to do, he'll have to write the code himself.

I see you have a "Call Delay" instruction in there. He's going to mail you back now and complain that it doesn’t work.
I must very careful when posting replies when situations like this.I'm Sorry SPDCHK.

#### prean

##### New Member
thank you guys for your help. it mean alot. i was just alil confused. but i think i understand now.

Status
Not open for further replies.