Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Reading from flash in Assembly

2004-12-02 by John Samperi

At 04:49 PM 2/12/04 -0000, you wrote:
>
>Made some changes, I wondered if I should be use .db instead of .EQU=, tried
>that, same thing.
>

.db puts the data in physically into the flash, .equ does NOT. So your
array MUST be made up by the define byte directive.

ORG 0200	;make it 0x0200 to be safe

array:		;assign a label
.db	0x00,0x01,0x02			;, etc ,etc

	ldi	xl,low(array*2)
	ldi	xh,high(array*2)	;x now points to the start of array

	add	xl,step			;I presume that step and num  are registers
	adc	xh,num			;x now should point to your data..(may need to multiply
somewhere)
	
	LPM  				;data in r0 or  LPM  r18,Z
...................				

ORG 0200	;make it 0x0200 to be safe

array:		;assign a label
.db	0x00,0x01,0x02			;, etc ,etc


>  MOV  r30,step  //this one 0-255?
>  MOV  r31,num   //this one 0-15?
>  SUBI r31,HIGH(-array)
>  LPM  r18,Z
>  OUT  PORTD,r18


Regards

John Samperi

******************************************************
                        Ampertronics Pty. Ltd.
  11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
         Tel. (02) 9674-6495       Fax (02) 9674-8745
               Email: samperi@ampertronics.com.au
                 Website  http://www.ampertronics.com.au
* Electronic Design   * Custom Products   * Contract Assembly
******************************************************

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.