Mikroelektronika MIKROE-350 データシート
FLASH_Read_Words
Library Example
The example demonstrates simple write to the flash memory for AVR, then reads the data and
displays it on PORTB and PORTD.
displays it on PORTB and PORTD.
program Flash_MCU_test
const F_ADDRESS as longint = 0x200
const data_ as word[32] = ( ' constant table
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F,
0x0000,0x0100,0x0200,0x0300,0x0400,0x0500,0x0600,0x0700,
0x0800,0x0900,0x0A00,0x0B00,0x0C00,0x0D00,0x0E00,0x0F00
0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F,
0x0000,0x0100,0x0200,0x0300,0x0400,0x0500,0x0600,0x0700,
0x0800,0x0900,0x0A00,0x0B00,0x0C00,0x0D00,0x0E00,0x0F00
) org 0x200
dim counter as byte
word_
as word
dat_buff
as word[32]
'dat_buff_ as word[32]
main:
DDRD = 0xFF ' set direction to be output
DDRB = 0xFF ' set direction to be output
DDRB = 0xFF ' set direction to be output
word_ = data_[0] ' link const table
216
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
' for MCUs with 64kb of Flash memory or less
sub procedure FLASH_Read_Words(dim address as word, dim buffer as
^word, dim NoWords as word)
sub procedure FLASH_Read_Words(dim address as word, dim buffer as
^word, dim NoWords as word)
' for MCUs with Flash memory larger than 64kb
sub procedure FLASH_Read_Words(dim address as longword, dim
buffer
sub procedure FLASH_Read_Words(dim address as longword, dim
buffer
as ^word, dim NoWords as word)
Returns
Nothing.
Description
Reads number of data words defined by
NoWords
parameter from the specified
address
in Flash memory to varibale pointed by
buffer
.
Requires
Nothing.
Example
'for MCUs with Flash memory larger than 64kb
const F_ADDRESS as longint = 0x200
dim dat_buff[32] as word
...
const F_ADDRESS as longint = 0x200
dim dat_buff[32] as word
...
FLASH_Read_Bytes(F_ADDRESS,dat_buff, 64)