1.8.6. Program Flash
The following registers are used to perform program flash:
- Operating protocols setting
- Control register
- Write instruction
Perform Page Program (Extended Mode)
proc page_program { } {
global mp operating_protocols_setting control_register write_instr
master_write_32 $mp $operating_protocols_setting 0x00000000
master_write_32 $mp $control_register 0x00000001
master_write_32 $mp $write_instr 0x00007002
master_write_32 $mp 0x00001000 0x1234abcd
}
To perform the page program for the extended mode, follow these steps:
- Define the global variables.
- Write to the operating protocols setting register to set the transfer mode of the program operation. In this example, the transfer mode for read is (1-1-1).
- Set the instruction transfer mode [1:0] to 0, write address transfer mode [5:4] to 0, and write data in transfer mode [9:8] to 0.
- Write to the control register to choose the byte addressing mode of the write operation.
- This example is using the 3-byte addressing mode. Set bit 8 to 0.
- Write to the write instruction register to customize the program operation.
- Set the write operation code [7:0] to 02 as 02h is the operation code for page program.
- Set the polling operation code [15:8] to 70 as 70h is the operation code for the read flag status register. After completing the write operation, the IP core releases the wait request of the Avalon® memory-mapped interface. For the flash that does not have the read flag status register, you can use the read status register (05h).
- After setting the registers, you can start to program the memory into the address.
- In this example, 1234abcdh is written to the memory address 0x00001000.
Perform 4-byte Quad Input Fast Program (Quad SPI Mode)
proc fourbyte_quad_input_fast_program { } {
global mp operating_protocols_setting control_register write_instr
master_write_32 $mp $operating_protocols_setting 0x00000222
master_write_32 $mp $control_register 0x00000101
master_write_32 $mp $write_instr 0x00007034
master_write_32 $mp 0x00002000 0xabcd1234
}
To perform the 4-byte quad input fast program, follow these steps:
- Define the global variables.
- Write to the operating protocols setting register to set the transfer mode of the program operation. In this example, the transfer mode for 4-byte quad input fast program is (4-4-4).
- Set the instruction transfer mode [1:0] to 2, write address transfer mode [5:4] to 2, and write data in transfer mode [9:8] to 2.
- Write to the control register to choose the byte addressing mode of the write operation.
- This example is using the 4-byte addressing mode. Set bit 8 to 1.
- Write to the write instruction register to customize the program operation.
- Set the write operation code [7:0] to 34 as 34h is the operation code for the 4-byte quad input fast program.
- Set the polling operation code [15:8] to 70 as 70h is the operation code for the read flag status register. After completing the write operation, the IP core releases the wait request of the Avalon® memory-mapped interface. For the flash that does not have the read flag status register, you can use the read status register (05h).
- After setting the registers, you can start to program the memory into the address.
- In this example, 1234abcdh is written to the memory address 0x00002000.
Did you find the information on this page useful?
Characters remaining: