Flash 2 click is a mikroBUS™ add-on board for adding more Flash Memory to your target board microcontroller. It carries Microchip’s SST26VF064B flash-memory module with 64 Mbits capacity. It’s a highly reliable module with a specified minimum of 100,000 read and write cycles and with over 100 years of Data Retention. For data security, the module features a One-Time Programmable (OTP) 2 KB bit secure ID and a 64 bit unique, factory pre-programmed identifier. Additional software security measures include inidividual-block write Protection with permanent lock-down capability. Flash 2 click communicates with the target MCU through the mikroBUS™ SPI interface (CS#, SCK, MISO, MOSI) with additional functionality provided by the #HOLD pin (in place of default mikroBUS™ RST pin). The board is designed to use a 3.3V power supply.
| Type | Flash |
| Applications | Ideal as a mass storage option in multimedia devices, drives, optical and printing devices. |
| On-board modules | Microchip’s SST26VF064B flash-memory module with 64 Mbits capacity |
| Key Features | 100,000 write cycles with 100 years of data retention. |
| Key Benefits | One-Time programmable 2 KB secure ID. 64 bit, factory pre-programmed identifier. |
| Interface | GPIO,SPI |
| Input Voltage | 3.3V |
| Compatibility | mikroBUS |
| Click board size | S (28.6 x 25.4 mm) |
The SST26VF064B/064BA memory array is organized in uniform, 4 KByte erasable sectors with the following erasable blocks:
The #HOLD pin temporarily stops serial communication with the SPI Flash memory while the device is selected. This pin only works in SPI, single-bit and dual-bit Read mode and must be tied high when not in use.
The manufacturer's data sheet has more information about the memory protection features of the chip:
"SST26VF064B/064BA offers flexible memory protection scheme that allows the protection state of each individual block to be controlled separately. In addition, the Write-Protection Lock-Down register prevents any change of the lock status during device operation. To avoid inadvertent writes during power-up, the device is write-protected by default after a power-on reset cycle. A Global Block Protection Unlock command offers a single command cycle that unlocks the entire memory array for faster manufacturing throughput."
This snippet initializes all necessary pins and functions for using Flash 2 Click, and performs a test by writing test values to the click, and then reading them back to the user through UART communication.
1 #include <stdint.h>
2 #include "flash_2_hw.h"
3
4 sbit FLASH_2_WP at GPIOA_ODR.B0;
5 sbit FLASH_2_CS at GPIOD_ODR.B13;
6 sbit FLASH_2_HLD at GPIOC_ODR.B2;
7
8 int main(void)
9 {
10
11 uint8_t buffer[4] = {15,20,25,30};
12 uint16_t count = 4;
13 uint32_t address = 0x0100F0;
14 uint8_t receive_buffer[4];
15 char tmp[20];
16
17 GPIO_Digital_Output( &GPIOA_BASE, _GPIO_PINMASK_0 );
18 GPIO_Digital_Output( &GPIOC_BASE, _GPIO_PINMASK_2 );
19 GPIO_Digital_Output( &GPIOD_BASE, _GPIO_PINMASK_13 );
20
21 SPI1_Init_Advanced( _SPI_FPCLK_DIV64,
22 _SPI_MASTER | _SPI_8_BIT | _SPI_CLK_IDLE_LOW |
23 _SPI_FIRST_CLK_EDGE_TRANSITION | _SPI_MSB_FIRST |
24 _SPI_SS_DISABLE | _SPI_SSM_ENABLE |
25 _SPI_SSI_1,
26 &_GPIO_MODULE_SPI3_PC10_11_12 );
27
28 Delay_ms(300);
29
30 UART1_Init(9600);
31 Delay_ms(300);
32
33 UART1_Write_Text( "Initializing Flash 2 click... " );
34 UART1_Write_Text( "rn" );
35 flash_2_init();
36 Delay_ms(300);
37 flash_2_global_block_unlock();
38 Delay_ms(400);
39 flash_2_write( address, buffer, count );
40 flash_2_read( address, receive_buffer, count );
41
42 UART1_Write_Text( "Initial Values: " );
43 while( count-- )
44 {
45 ByteToStr( buffer[count], tmp );
46 UART1_Write_Text( tmp );
47 }
48 UART1_Write_Text( "rn" );
49 count = 4;
50
51 UART1_Write_Text( "Received Values: " );
52 while( count -- )
53 {
54 ByteToStr( receive_buffer[count], tmp );
55 UART1_Write_Text( tmp );
56 }
57 UART1_Write_Text( "rn" );
58
59 return;
60 }
Code examples that demonstrate the usage of Flash 2 click with MikroElektronika hardware, written for mikroC for ARM, AVR, dsPIC, FT90x, PIC and PIC32 are available on Libstock