stm8教程实验16-spi总线 w25x16

合集下载

STM8教程实验16-SPI总线+W25X16

STM8教程实验16-SPI总线+W25X16

例程十六SPI_Flash的读写在这个例程中我们将要了解一下SPI,SPI也是跟I2C一样也是有硬件来实现的。

SPI一般有4根线,一条时钟线CLK,2条数据线(MISO和MOSI),1条片选信号线。

如果大家想了解更多关于SPI的话,大家可以参考“STM8寄存器.pdf”文档。

里面有更详细的解释以说明。

我们平时多用到的是SPI主模式,跟I2C一样。

下面讲一下SPI主模式一些关于常见初始化和配置的知识都讲了,下面我们从主函数看起,逐步分析:SPI_FLASH_Init() SPI的初始化看看函数原型:SPI_Init()配置了数据位高位先发送,SPI 的传输的波特率为系统频率的2分频,SPI为工作在主模式,当SPI处于空闲状态时时钟线处于高电平,数据在第二个时钟传输周期被锁,数据线为全双工,使用软件方式代替使用NSS管脚,使用CRC校验。

SPI_Cmd()时能SPI设置片选信号线,先把它置高。

初始化弄好了,下面来看看怎样往从设备读写,首先是读写一个字节。

我们开发板上的从设备上W25X16的,所以我们要根据W25X16的Datasheet来配置一下参数。

这个函数就是在SPI总线上读写一个字节的操作,是根据SPI总线的时序来完成的。

可以参考数据传输过程那里的说明。

这个函数就是往W25X16的写数据的写使能,参考一下的时序准备写一个数据,参考时序往W25X16的一页写数据,每页做多能写4102Byte。

这个函数是往任何地址写任何多个Byte的数据,直到写满为止,最大2Mbyte。

这个函数是往任何地址读任何个字节的数据缓存在pBuffer中。

读W25X16的ID号,参考时序擦除一个Block的数据,参考时序:擦除整个Flash,参考时序主要的功能函数模块都讲完了,还有一些测试时候写的测试其他的函数,有兴趣的可以看下工程。

实验效果:风驰电子祝您学习愉快~~~!!!!!。

小菲教你STM8单片机基础入门

小菲教你STM8单片机基础入门
STM8S主要特点:
速度达20 MIPS的高性能内核 抗干扰能力强,品质安全可靠 领先的130纳米制造工艺,优异的性价比 程序空间从4K到128K, 芯片选择从20脚到80脚,宽范围产品系列 系统成本低,内嵌EEPROM和高精度RC振荡器 开发容易,拥有本地化工具支持
STM8S主要应用:
STM8L主要特点:
STM8 16 MHz CPU 内置 4-32 KB 闪存,多达 2KB SRAM 三个系列:跨系列的引脚对引脚兼容、软件相互兼容、外设相互兼容 电源电压:1.8 V-3.6 V (断电时,最低 1.65 V) 超低功耗模式:保持 SRAM 内容时,最低功耗 350nA 运行模式动态功耗低至 150μA/MHz 最先进的数字和模拟外设接口 工作温度范围:-40°C 到+85 °C,可高达 125 °C 免费的触感固件库
王志杰 Email: iewangzhijie@ QQ:411238869
1 STM8 微控制器简介
-7-
1.3 STM8A 系列
意法半导体公司推出的 STM8A 是一款专门用于满足汽车应用的特殊需求的 8-位 Flash 微控制器。这些模块化产品提供了真数据 EEPROM 以及软件和引脚兼容性,适用的程序存 储器尺寸范围为 8KB 至 256KB 和 20 至 128-引脚封装。所有器件的工作电压均为 3V 至 5V, 并且其工作温度扩展到了 145°C。
监控、紧急求助
王志杰 Email: iewangzhijie@ QQ:411238869
1 STM8 微控制器简介
-4-
STM8S 产品分为“Access Line(入门级)”和“Peroformance Line(增强型)”,如 下图所示。
王志杰 Email: iewangzhijie@ QQ:411238869

stm8l05xx,stm8l15xx和stm8l16xx中文参考手册(完整版)资料

stm8l05xx,stm8l15xx和stm8l16xx中文参考手册(完整版)资料

本参考手册的目标应用程序开发人员。

它提供了完整的信息如何使用stm8l05xx,stm8l15xx 和stm8l16xx微控制器的存储器和外围设备。

该stm8l05xx / stm8l15xx / stm8l16xx是一个家庭的不同存储密度的微控制器和外围设备。

这些产品是专为超低功耗应用。

可用的外设的完整列表,请参阅产品数据表。

订购信息,引脚说明,机械和电气设备的特点,请参阅产品数据表。

关于STM8 SWIM通信协议信息和调试模块,请参阅用户手册(um0470)。

在STM8的核心信息,请参阅STM8的CPU编程手册(pm0044)。

关于编程,擦除和保护的内部快闪记忆体,请参阅STM8L闪存编程手册(pm0054)。

1 中央处理单元(CPU)。

30。

1.1 引言301.2 CPU的寄存器。

30。

1.2.1 描述CPU寄存器。

..。

301.2.2 STM8 CPU寄存器图。

..。

341.3 全球配置寄存器(cfg_gcr)。

34。

1.3.1 激活水平。

..。

341.3.2 游泳禁用。

..。

351.3.3 描述全局配置寄存器(cfg_gcr)。

..。

35 1.3.4 全局配置寄存器图及复位值。

..。

352 启动ROM . . . 363程序存储器和数据存储器。

37。

3.1引言373.2术语。

37。

3.3个主要的快闪存储器的特点。

38。

3.4记忆的组织。

39。

3.4.1低密度设备的存储器组织。

393.4.2介质密度的装置记忆的组织。

..。

403.4.3介质+密度装置记忆的组织。

..。

413.4.4高密度存储器组织。

..。

423.4.5专有代码区(译)。

433.4.6用户区(UBC)。

433.4.7数据的EEPROM(数据)。

..。

463.4.8主程序区。

463.4.9选项字节。

..。

463.5内存保护。

47。

3.5.1读出保护。

473.5.2内存访问安全系统(质量)。

473.5.3使写访问选项字节。

493.6内存编程493.6.1同时读写(读写网)。

16位单片机实验指导书

16位单片机实验指导书

16位单片机应用实验指导书电子与信息工程学院2O15年2月实验一MC9S12XS128入门实验一.实验目的1.熟悉CodeWarrior嵌入式开发系统软硬件环境,掌握其使用方法及调试方式。

2.掌握S12 GPIO接口的使用方法及编程方法。

3.熟悉S12单片机的C语言程序编程框架。

4.理解样例中的第一个C语言程序代码。

二.实验设备及其连接1.PC机一台2.S12嵌入式开发实验板一套3.接线原理图实验板上有8个发光二级管和4个按钮开关, 8个发光二级管由单片机的PB口8个IO引脚控制, PB0-PB7输出低电平时LED点亮, 输出高电平时LED熄灭。

4个独立的按键输入直接连接到PP口的PP4-PP7引脚, 常态下为高电平, 按键按下时, CPU相应I/O引脚将检测到低电平, XS128芯片的PP口是有中断功能的IO口, 除了可用查询方式检测IO口的状态以外,我们也可以用中断的方式读入按键的状态。

三.实验内容1.使用CodeWarrior嵌入式开发系统的软硬件环境,掌握其使用方法及调试方式。

2.调试运行提供的样例程序light,观看实验结果。

(软件使用参见第四部分)3.运行样例程序,观察小灯的闪烁和对应的程序实现;调整延时的长短,继续观察小灯的闪烁。

4.尝试新建自己的工程,自编程序,实现用4个开关控制4个小灯的亮灭. 4个开关分别接在端口P的PTP4~PTP7口,4个小灯则接在PORTB0~PORTB3口, 参见第二部分连接图. 编程实现用这4个开关控制4个小灯,按钮开关按下时,对应小灯亮,否则为暗。

提示:新建工程时芯片选择HCS12X family-〉mc9s12xs128,connection 选择TBDML,然后下一步输入工程路径和名称,再3次下一步,选择默认选项,然后下一步、完成。

在main.c 文件中加入你的代码,主要通过设置数据方向寄存器DDRB DDRP和数据寄存器PORTB PTP来实现开关控制小灯的功能。

STM8开发板原理图

STM8开发板原理图

D1 LED1
D2 LED2
按键3
C14 GND 104
第四版原理图
PC3 OSI J1 4 3 2 1 VDD SWIM GND RST C2 22 16M Y1 GND C3 22 OSO
PC4
PD2
B
仿真器接口
SWIM
HSE
LED
KEY
FLASH
B
J2 VDD R1 1032 NRST J4 C4 104 GND VDD S4 3 2 1 CON3 5VIN
PD7/TLI/T1_C4 PD6/UART1_RX PD5/UART1_TX PD4/BEEP/T2_C1 PD3/T2_C2/ADC_ETR PD2/T2_C3 PD1/SWIM PD0/_T1_BKIN PC7/SPI_MISO PC6/SPI_MOSI PC5/SPI_SCK PC4/T1_C4/CCO PC3/T1_C3 PC2/T1_C2 PC1/T1_C1/UART1_CK PE5/SPI_NSS
跳线
C10 104 GND
MINIUSB接口 XI Y2 XO
电源选择跳线
蜂鸣器
LS1
VDD
R3 103
多用途液晶接口
光敏电阻
Q1 PNP
OLED直接插/段码液晶电路板上靠右侧插
GND Title
D
双跳线
USB转TTL
1 2 3
蜂鸣器
4
ADC
5
B Date: File:
32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17
PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0 PC7 PC6 PC5 PC4 PC3 PC2 PC1 PE5

W25Q16BV操作程序

W25Q16BV操作程序

如题,用菜农老师的助学板写的。

以前俺都习惯用模拟的SPI去解决问题,用这个板子试了下自带的SPI 控制器。

板子上是用W25Q16BV这款SPI接口的FLASH,这块片子是华邦出的,去DataSheet网上找居然没有,后来去华邦的官网下载了。

他由8192个可编程的页组成,每页有256bytes。

一次可写256bytes,可以sector、BLOCK、whole chip擦除。

具体擦除的指令可以参照其Datasheet,我就不说了。

下面附上程序,整个工程见附件:/*---------------------------------------------------------------------------------------------------------*//* *//* Copyrightp; *//*---------------------------------------------------------------------------------------------------------*//******************************************************************************文件名:W25Q16BV_Function.c说明:本文件为“NUC120RE3AN用SPI总线主机模式读写W25Q16BV的主函数。

UART的波特率为115200。

申明:本程序参考三心的spi程序和板子自带的BSP例程,运用中断模式。

谢谢。

开始:2011.8.23修改:V1.0******************************************************************************/#include <stdio.h>#include "NUC1xx.h"#include "DrvUART.h"#include "DrvSYS.h"#include "DrvSPI.h"#include "global.h"int main(){SYSTEM_Config();UART_Config();GPIO_Config();W25Q16BV_SPI_Init();printf("\n\n");printf("+----------------------------------------------------------------------+\n");printf("| 菜农老师助学板之SPI操作W25Q16BV |\n");printf("| |\n");printf("+----------------------------------------------------------------------+\n");printf("\n");printf("配置SPI1为主机模式.\n");printf("SPI1 时钟为: %d Hz\n", DrvSPI_GetClock1Freq(eDRVSPI_PORT1));while(1){if(SPI_Start_Flag==TRUE){SPI_Start_Flag=FALSE;printf("开始操作SPI\n");switch(UART_Buffer_Rx){case 'R':case 'r':printf("Read data from W25Q16BV ...\n");W25Q16BV_SPI_ReadFlash();break;case 'W':case 'w':printf("Write data to W25Q16BV ...\n");DrvSYS_Delay(1000);W25Q16BV_SPI_PageProgram();printf("Write Flash Over!\n");break;default:printf("您输入的指令有误!\n");}}}}#include <stdio.h>#include "NUC1xx.h"#include "DrvUART.h"#include "DrvSYS.h"#include "DrvSPI.h"#include "DrvGPIO.h"#include "Drive_Function.h"#define Enable_SPI1_W25Q16BV DrvGPIO_ClrBit(E_GPA, 14)#define Disable_SPI1_W25Q16BV DrvGPIO_SetBit(E_GPA, 14)//extern uint32_t SPI_TX_DATA_Buffer[256];//extern uint32_t SPI_RX_DATA_Buffer[256];extern uint32_t SPI_RX_DATA;extern uint32_t Write_Enable;extern uint32_t Write_Disable;extern uint32_t Read_Status_Register1;extern uint32_t Read_DATA;extern uint32_t Page_Program;extern uint32_t Sector_Erase;extern uint32_t Chip_Erase;extern uint32_t Read_ID;extern uint32_t Addr;extern uint8_t SPI_DATA_Buffer[256];extern volatile uint8_t count;extern volatile uint32_t g_Spi1IntFlag;extern volatile uint8_t W25Q16BV_BUSY_Flag;extern uint32_t u32Tmp;void W25Q16BV_SPI_Init(){/*开SPI1总线设置为主机模式,波形1*/DrvSPI_Open(eDRVSPI_PORT1, eDRVSPI_MASTER, eDRVSPI_TYPE1, 32,FALSE);/*设置为MSP优先传输MSB*/DrvSPI_SetEndian(eDRVSPI_PORT1, eDRVSPI_MSB_FIRST);/*从机选择线低电平或者下降沿激活*/DrvSPI_SetSlaveSelectActiveLevel(eDRVSPI_PORT1, eDRVSPI_ACTIVE_LOW_FALLING);/*SPI总线的速率设置为1MHZ*/DrvSPI_SetClockFreq(eDRVSPI_PORT1, 1000000, 0);/*使能W25Q16BV 的片选信号*/Enable_SPI1_W25Q16BV;/*开启SPI1总线中断,并且与回调函数SPI1_Callback挂钩*/ DrvSPI_EnableInt(eDRVSPI_PORT1, SPI1_Callback, 1);}void W25Q16BV_SPI_PageProgram(){uint16_t i;uint32_t au32SourceData;/*使能SPI1中断,且SPI1_Callback为其回调函数*/DrvSPI_EnableInt(eDRVSPI_PORT1, SPI1_Callback, 0);/*中断标志清0*/g_Spi1IntFlag=0;/*使能W25Q16BV*/Enable_SPI1_W25Q16BV;/* Set the bit length of SPI transfer. */DrvSPI_SetBitLength(eDRVSPI_PORT1,8);/*写使能*/au32SourceData=0x06;printf("发送写能W25Q16BV\n");DrvSPI_SingleWrite(eDRVSPI_PORT1, &au32SourceData);/*等待传输完毕*/while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;printf("写能W25Q16BV指令发送完毕\n");/*关闭CS*/Disable_SPI1_W25Q16BV;/*打开CS*/Enable_SPI1_W25Q16BV;printf("Page_Program指令开始发送\n");au32SourceData=0x02;DrvSPI_SingleWrite(eDRVSPI_PORT1, &au32SourceData);/*等待传输完毕*/while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;DrvSPI_SetBitLength(eDRVSPI_PORT1,24);au32SourceData=0x0000;DrvSPI_SingleWrite(eDRVSPI_PORT1, &au32SourceData);/*等待传输完毕*/while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;printf("Page_Program指令已经发送完毕\n");DrvSPI_SetBitLength(eDRVSPI_PORT1,8);for(i=0;i<256;i++){SPI_DATA_Buffer[i]=0x02;au32SourceData=SPI_DATA_Buffer[i];DrvSPI_SingleWrite(eDRVSPI_PORT1,&au32SourceData);/*等待传输完毕*/while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;printf("写入的值为: %d\n", SPI_DATA_Buffer[i]);}Disable_SPI1_W25Q16BV;}void W25Q16BV_SPI_ReadFlash(){uint32_t au32SourceData;uint16_t i;/*中断标志清0*/g_Spi1IntFlag=0;/*使能SPI1中断,且SPI1_Callback为其回调函数*/ DrvSPI_EnableInt(eDRVSPI_PORT1, SPI1_Callback, 0);/*设置传输的长度*/DrvSPI_SetBitLength(eDRVSPI_PORT1,8);/*使能W25Q16BV*/Enable_SPI1_W25Q16BV;/*读操作指令*/au32SourceData=0X03;/*写入指令*/DrvSPI_SingleWrite(eDRVSPI_PORT1, &au32SourceData);/*等待传输完毕*/printf("开始写读命令字和地址\n");while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;printf("写完读命令字和地址\n");/*设置传送长度为24位*/DrvSPI_SetBitLength(eDRVSPI_PORT1,24);/*传送地址*/au32SourceData=0X0000;DrvSPI_SingleWrite(eDRVSPI_PORT1, &au32SourceData);/*等待传输完毕*/while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;DrvSPI_SetBitLength(eDRVSPI_PORT1,8);for(i =0; i<256; i++){au32SourceData=0x0;/*开始接收数据*/DrvSPI_SingleWrite(eDRVSPI_PORT1, &au32SourceData); /*等待传输完毕*/while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;/*读取收到的数据*,并且不触发下一次传送*/DrvSPI_DumpRxRegister(eDRVSPI_PORT1, &SPI_RX_DATA, 1);/*打印收到的数据*/SPI_DATA_Buffer[i]=(uint8_t)SPI_RX_DATA;printf("0x%X ",SPI_DATA_Buffer[i]);if ((i%10)==6)printf("\n");}printf("所有数据接收完毕\n");Disable_SPI1_W25Q16BV;}void W25Q16BV_SPI_ChipErase(){/*使能SPI1中断,且SPI1_Callback为其回调函数*/DrvSPI_EnableInt(eDRVSPI_PORT1, SPI1_Callback, 0);/*中断标志清0*/g_Spi1IntFlag=0;/*使能W25Q16BV*/Enable_SPI1_W25Q16BV;/* Set the bit length of SPI transfer. */DrvSPI_SetBitLength(eDRVSPI_PORT1,8);/* write the first data of source buffer to Tx register of SPI0. And start transmission. */ DrvSPI_SingleWrite(eDRVSPI_PORT1, &Write_Enable);/*等待传输完毕*/while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;/*关闭CS*/Disable_SPI1_W25Q16BV;DrvSPI_SetBitLength(eDRVSPI_PORT1,8);/*打开CS*/Enable_SPI1_W25Q16BV;DrvSPI_SingleWrite(eDRVSPI_PORT1, &Chip_Erase);/*等待传输完毕*/while(g_Spi1IntFlag==0);g_Spi1IntFlag=0;Disable_SPI1_W25Q16BV;}void SPI1_Callback(uint32_t u32UserData) {g_Spi1IntFlag = 1;}。

w25q16数据手册_引脚图_参数

w25q16数据手册_引脚图_参数

8.
QUAD ENABLE (QE) – VOLATILE/NON-VOLATILE WRITABLE .............................................. 14
Write Protect Selection (WPS) – Volatile/Non-Volatile Writable ........................................15
4.3 Write Protect (/WP)............................................................................................................... 7
4.4 HOLD (/HOLD) ..................................................................................................................... 7
6.1 Standard SPI Instructions..................................................................................................... 9
6.2 Dual SPI Instructions ............................................................................................................ 9
Write Enable Latch (WEL) – Status Only...........................................................................11

W25X16中文手册

W25X16中文手册


W25X16,W25X32,W25X64
描封
脚类IC 态0时m除l
PDIP 总00m除l
PAD封N类
PAD封NAM状
1
/CS
I
2
DO
O
3
/WP
I
4
GND
5
DIO
I/O
6
CLK
I
7
/HOLD
I
8
VCC
擦封脚类IC 总00m除l
W脚类N 描×指MM
I/类
F芯NCTI类N
/
时封脚类IC 总00m除l
9Fh
ID
ID
DO
DIO CLK

ID ID
ID 8
email:richgood@
17
W25X16\W25X32\W25X64
Cortex-M0

JEDEC ID
ID Manufa部turer an释 Dev除部e I释ent除f除部at除on
ration
PAD封N类 1 2
W25X16,W25X32,W25X64
PAD封NAM状
I/类
/HOLD
I
VCC
email:richgood@
3
F芯NCTI类N
W25X16\W25X32\W25X64
Cortex-M0
3
N/C
4
N/C
5
N/C
6
N/C
7
/CS
I
8
DO
O
9
/WP
I
10
GND
11
N/C
12
N/C
13
N/C

STM8CubeMX中文版用户使用手册

STM8CubeMX中文版用户使用手册

2 开始使用 STM8CubeMX ..................................................................................................2
1、原则 .......................................................................................................................... 2
4.1 欢迎页面 ................................................................................................................16
4.2 新工程窗口 ............................................................................................................17
4.4.1 文件菜单 .....................................................................................................20
4.4.2 工程菜单 .....................................................................................................21
4.3 主界面 ....................................................................................................................19

STM8教程实验22-SPI总线+SD卡+系统文件的读写

STM8教程实验22-SPI总线+SD卡+系统文件的读写

2/5
风驰电子 STM8 开发板
2011
一般最常用的就是这几个函数,其实大家看了它的英文注释也大概了解到这 个函数的意思了吧。大家结合例程中的例子进行简单的分析下。 f_mount(0, &myfs[0]); 在文件系统注册一个工作区, 这个工作区的设备号为 0, 相对于盘符的意思, 这个参数开设为 0~9, &myfs[0]是指向工作区的指针。 一般定义 myfs 为 FATFS 类型,这个 FATFS 是个结构体类型的。 f_open( &myfsrc , "0:/My__Demo.TXT" , FA_CREATE_NEW | FA_WRITE);这个函 数的意思是在刚刚开辟盘符 0 下一个以只写的方式打开文件名为 My__Demo.TXT 的文件, 如果该文件不存在, 就新建一个名为 My__Demo.TXT。 该文件是关联到 myfsrc 这个结构体指针的,在之后的文件读写都是通过该结 构体去完成的。 myres = f_write(&myfsrc, mystring, sizeof(mystring), &mybr);这个函数就要把你 要写的信息写进刚才创建或打开的 My__Demo.TXT 中。 f_close(&myfsrc); 关闭文件。 f_read( &myfsrc, save_buffer, sizeof(save_buffer), &mybr );这个函数就是从已经 打开的文件里读出数据放在 save_buffer。 但是从应用层方面来说,会运用上面所说那几个函数就可以了,会使用这几 个函数就会了对系统文件的读写,就可以做更多东西了,接下那 2 讲的教程 就是要用到这几个函数对系统文件的读写。我们期待着下 2 讲教程。 下面就是看看主函数

W25X16-32-64

W25X16-32-64

W25X16, W25X32, W25X64Publication Release Date: February 26, 2007, Revision E- 1 -首先个人对此芯片的了解仅供参考:以下是我个人针对flash w25x32芯片的总结:1. 对flash 写数据。

前提要做好必要的处理,首先要写入状态(取消写保护),写状态要15ms 时间,写状态之前要打开写使能,状态写完会自动关闭写使能。

其次是擦除(最小可以擦除一个扇区4k ,需要时间300ms ;其次区域大些可以块擦除64k ,需要2s ;也可以整个芯片擦除,但需要80s ),擦除之前要打开写使能,擦除完会自动关闭写使能。

最后可以写数据了,当然写数据之前要打开写使能,写完一次会自动关闭写使能,所以下一次写之前又要打开写使能,还有每次写数据的间隔要延时3ms ,读数据不需要延时。

2. 由于芯片中分了页,扇区,块,所以连写多个字节的数据时肯定会涉及到跨页和跨扇区。

跨页或者跨扇区是不能连写的,如果每次写的字节是不定的那只能拆开写,如果每次写的字节是固定的个数(256能整除以的数),所以连写时要处理好跨页或者跨扇区的问题。

3. 如果该扇区中有被写保护则扇区擦除和块擦除会失败,其它扇区可以被擦除,只要被擦除的区域没有保护着。

如果是整个芯片擦除只要是有写保护在,则整块芯片会擦除失败。

/////////////////////////////下面是延时说明仅供参考///////////////////////////////// 1. 单字节写:50us2. 连写:第一个字节50us ,之后5us 一个字节3. 写状态寄存器:10ms4. 扇区擦除:90ms5. 块擦除:650ms6. 片擦除:40s7.以上是用示波器通过I/O 变化测得的数据************************************************************** 以下是规格书上的8. Write Status Register Time 10 ~15 ms 9. Byte Program Time (First Byte) 100~ 150 µs10. Additional Byte Program Time (After First Byte) 6 ~12 µs 11. Page Program Time 1.6~ 3 ms 12. Sector Erase Time (4KB) 150~ 300 ms 13. Block Erase Time (64KB) 0.8 ~2 s 14. Chip Erase Time W25X32 40~ 80sW25X16, W25X32, W25X64- 2 -16M-BIT, 32M-BIT, AND 64M-BIT SERIAL FLASH MEMORY WITH4KB SECTORS AND DUAL OUTPUT SPIW25X16, W25X32, W25X64Publication Release Date:February 26, 2007, Revision E- 3 -Table of Contents1. GENERAL DESCRIPTION ......................................................................................................... 4 2. FEATURES ................................................................................................................................. 4 3. PIN CONFIGURATION SOIC 208-MIL....................................................................................... 5 4. PIN CONFIGURATION WSON 6X5-MM .................................................................................... 5 5. PIN CONFIGURATION PDIP 300-MIL ....................................................................................... 6 6. PIN DESCRIPTION SOIC 208-MIL, PDIP 300-MIL, AND WSON 6X5-MM ............................... 6 7. PIN CONFIGURATION SOIC 300-MIL (7)8.PIN DESCRIPTION SOIC 300-MIL (7)8.1 Package Types ............................................................................................................... 8 8.2 Chip Select (/CS) ............................................................................................................ 8 8.3 Serial Data Output (DO) ................................................................................................. 8 8.4 Write Protect (/WP) ......................................................................................................... 8 8.5 HOLD (/HOLD) ............................................................................................................... 8 8.6 Serial Clock (CLK) .......................................................................................................... 8 8.7Serial Data Input / Output (DIO) (8)9. BLOCK DIAGRAM (9)10.FUNCTIONAL DESCRIPTION (10)10.1SPI OPERATIONS (10)10.1.1 SPI Modes ....................................................................................................................10 10.1.2 Dual Output SPI............................................................................................................10 10.1.3Hold Function (10)10.2WRITE PROTECTION (11)10.2.1Write Protect Features (11)11.CONTROL AND STATUS REGISTERS (12)11.1STATUS REGISTER (12)11.1.1 BUSY............................................................................................................................12 11.1.2 Write Enable Latch (WEL) ............................................................................................12 11.1.3 Block Protect Bits (BP2, BP1, BP0) ..............................................................................12 11.1.4 Top/Bottom Block Protect (TB) .....................................................................................12 11.1.5 Reserved Bits ...............................................................................................................12 11.1.6 Status Register Protect (SRP) ......................................................................................13 11.1.7Status Register Memory Protection (14)11.2 INSTRUCTIONS (16)11.2.1 Manufacturer and Device Identification.........................................................................16 11.2.2 Instruction Set...............................................................................................................17 11.2.3Write Ensable (06h) (18)W25X16, W25X32, W25X64- 4 -11.2.4 Write Disable (04h) .......................................................................................................18 11.2.5 Read Status Register (05h) ..........................................................................................19 11.2.6 Write Status Register (01h) ..........................................................................................20 11.2.7 Read Data (03h) ...........................................................................................................21 11.2.8 Fast Read (0Bh) ...........................................................................................................22 11.2.9Fast Read Dual Output (3Bh) (23)11.2.10 Page Program (02h) ...................................................................................................24 11.2.11 Sector Erase (20h) .....................................................................................................25 11.2.12 Block Erase (D8h) ......................................................................................................26 11.2.13 Chip Erase (C7h) ........................................................................................................27 11.2.14 Power-down (B9h) ......................................................................................................28 11.2.15 Release Power-down / Device ID (ABh) .....................................................................29 11.2.16 Read Manufacturer / Device ID (90h) .........................................................................31 11.2.17 JEDEC ID (9Fh). (32)12.ELECTRICAL CHARACTERISTICS (PRELIMINARY) (33)12.1 Absolute Maximum Ratings .......................................................................................... 33 12.2 Operating Ranges......................................................................................................... 33 12.3 Endurance and Data Retention .................................................................................... 34 12.4 Power-up Timing and Write Inhibit Threshold .............................................................. 34 12.5 DC Electrical Characteristics ........................................................................................ 35 12.6 AC Measurement Conditions........................................................................................ 36 12.7 AC Electrical Characteristics ........................................................................................ 37 12.8 AC Electrical Characteristics (Cont’d) .......................................................................... 38 12.9Serial Output Timing (39)12.10 Input Timing................................................................................................................. 39 12.11 Hold Timing .. (39)13.PACKAGE SPECIFICATION (40)13.1 8-Pin SOIC 208-mil (Package Code SS)...................................................................... 40 13.2 8-Pin PDIP 300-mil (Package Code DA) ...................................................................... 41 13.3 8-contact 6x5 WSON .................................................................................................... 42 13.4 8-contact 6x5 WSON (Cont’d) ...................................................................................... 43 13.516-Pin SOIC 300-mil (Winbond Package Code SF) (44)14.ORDERING INFORMATION (45)15.REVISION HISTORY (46)W25X16, W25X32, W25X64Publication Release Date: February 26, 2007, Revision E- 5 -1. GENERAL DESCRIPTIONThe W25X16 (16M-bit), W25X32 (32M-bit), and W25X64 (64M-bit) Serial Flash memories provide a storage solution for systems with limited space, pins and power. The 25X series offers flexibility and performance well beyond ordinary Serial Flash devices. They are ideal for code download applications as well as storing voice, text and data. The devices operate on a single 2.7V to 3.6V power supply with current consumption as low as 5mA active and 1µA for power-down. All devices are offered in space-saving packages.The W25X16/32/64 array is organized into 8,192/16,384/32,768 programmable pages of 256-bytes each. Up to 256 bytes can be programmed at a time using the Page Program instruction. Pages can be erased in groups of 16 (sector erase), groups of 256 (block erase) or the entire chip (chip erase). The W25X16/32/64 has 512/1024/2048 erasable sectors and 32/64/128 erasable blocks respectively. The small 4KB sectors allow for greater flexibility in applications that require data and parameter storage. (See figure 2.)The W25X16/32/64 supports the standard Serial Peripheral Interface (SPI), and a high performance dual output SPI using four pins: Serial Clock, Chip Select, Serial Data I/O and Serial Data Out. SPI clock frequencies of up to 75MHz are supported allowing equivalent clock rates of 150MHz when using the Fast Read Dual Output instruction. These transfer rates are comparable to those of 8 and 16-bit Parallel Flash memories.A Hold pin, Write Protect pin and programmable write protect, with top or bottom array control features, provide further control flexibility. Additionally, the device supports JEDEC standard manufacturer and device identification.2. FEATURES• Family of Serial Flash Memories– W25X16: 16M-bit / 2M-byte (2,097,152) – W25X32: 32M-bit / 4M-byte (4,194,304) – W25X64: 64M-bit / 8M-byte (8,388,608) – 256-bytes per programmable page– Uniform 4K-byte Sectors / 64K-byte Blocks• SPI with Single or Dual Outputs– Clock, Chip Select, Data I/O, Data Out – Optional Hold function for SPI flexibility• Data Transfer up to 150M-bits / second – Clock operation to 75MHz– Fast Read Dual Output instruction – Auto-increment Read capability• Flexible Architecture with 4KB sectors – Sector Erase (4K-bytes) – Block Erase (64K-byte)– Page program up to 256 bytes <2ms – Up to 100,000 erase/write cycles – 20-year retention• Low Power Consumption, Wide Temperature Range– Single 2.7 to 3.6V supply– 5mA active current, 1µA Power-down (typ) – -40° to +85°C operating range• Software and Hardware Write Protection – Write-Protect all or portion of memory – Enable/Disable protection with /WP pin – Top or bottom array protection• Space Efficient Packaging– 8-pin SOIC 208-mil (W25X16, X32)– 8-pin PDIP 300-mil (W25X16, X32, X64) – 16-pin SOIC 300-mil (W25X16, X32, X64) – 8-pad WSON 6x5-mm (W25X16)– 8-pad WSON 8x6-mm (W25X32, X64)W25X16, W25X32, W25X64- 6 -3. PIN CONFIGURATION SOIC 208-MILFigure 1a. W25X16 and W25X32 Pin Assignments, 8-pin SOIC (Package Code SS)Figure 1b. W25X16 Pin Assignments, 8-pin WSON (Package Code ZP)W25X16, W25X32, W25X64Publication Release Date: February 26, 2007, Revision E- 7 -5. PIN CONFIGURATION PDIP 300-MILFigure 1c. W25X16, W25X32, W25X64 Pin Assignments, 8-pin PDIP (Package Code DA)6. PIN DESCRIPTION SOIC 208-MIL, PDIP 300-MIL, AND WSON 6X5-MMPAD NO. PAD NAME I/O FUNCTION1 /CS I Chip Select Input2 DO O Data Output3 /WP IWrite Protect Input 4 GNDGround5 DIO I/O Data Input / Output6 CLK I Serial Clock Input7 /HOLD IHold Input 8VCCPower SupplyW25X16, W25X32, W25X64- 8 -7. PIN CONFIGURATION SOIC 300-MILFigure 1d. W25X16, W25X32 and W25X64 Pin Assignments, 16-pin SOIC 300-mil (Package Code SF)8. PIN DESCRIPTION SOIC 300-MILPAD NO. PAD NAME I/O FUNCTION1 /HOLD I Hold Input2 VCC Power Supply3 N/C No Connect4 N/C No Connect5 N/C No Connect6 N/CNo Connect7 /CS I Chip Select Input 8 DO O Data Output 9 /WP IWrite Protect Input 10 GND Ground 11 N/C No Connect 12 N/C No Connect 13 N/C No Connect 14 N/CNo Connect15 DIO I/O Data Input / Output 16 CLKISerial Clock InputW25X16, W25X32, W25X64Publication Release Date: February 26, 2007, Revision E- 9 -8.1 Package TypesAt the time this datasheet was published not all package types had been finalized. Contact Winbond to confirm availability of these packages before designing to this specification. W25X16 and W25X32 are offered in an 8-pin plastic 208-mil width SOIC (package code SS). The W25X16 in 6x5-mm WSON (package code ZP) and 25X32 and 25X64 in 8x6-mm WSON. (package code ZE). The 25X16, W25X32 and W25X64 are offered in 16-pin plastic 300-mil width SOIC (package code SF) and 300- mil DIP (package code DA). See figures 1a-d. Package diagrams and dimensions are illustrated at the end of this datasheet.8.2 Chip Select (/CS)The SPI Chip Select (/CS) pin enables and disables device operation. When /CS is high the device is deselected and the Serial Data Output (DO) pin is at high impedance. When deselected, the devices power consumption will be at standby levels unless an internal erase, program or status register cycle is in progress. When /CS is brought low the device will be selected, power consumption will increase to active levels and instructions can be written to and data read from the device. After power-up, /CS must transition from high to low before a new instruction will be accepted. The /CS input must track the VCC supply level at power-up (see “Write Protection” and figure 20). If needed a pull-up resister on /CS can be used to accomplish this.8.3 Serial Data Output (DO)The SPI Serial Data Output (DO) pin provides a means for data and status to be serially read from (shifted out of) the device. Data is shifted out on the falling edge of the Serial Clock (CLK) input pin.8.4 Write Protect (/WP)The Write Protect (/WP) pin can be used to prevent the Status Register from being written. Used in conjunction with the Status Register’s Block Protect (BP2, BP1, and BP0) bits and Status Register Protect (SRP) bits, a portion or the entire memory array can be hardware protected. The /WP pin is active low.8.5 HOLD (/HOLD)The /HOLD pin allows the device to be paused while it is actively selected. When /HOLD is brought low, while /CS is low, the DO pin will be at high impedance and signals on the DIO and CLK pins will be ignored (don’t care). When /HOLD is brought high, device operation can resume. The /HOLD function can be useful when multiple devices are sharing the same SPI signals. (“See Hold function”)8.6 Serial Clock (CLK)The SPI Serial Clock Input (CLK) pin provides the timing for serial input and output operations. ("See SPI Operations")8.7 Serial Data Input / Output (DIO)The SPI Serial Data Input/Output (DIO) pin provides a means for instructions, addresses and data to be serially written to (shifted into) the device. Data is latched on the rising edge of the Serial Clock (CLK) input pin. The DIO pin is also used as an output when the Fast Read Dual Output instruction is executed.W25X16, W25X32, W25X64- 10 -9. BLOCK DIAGRAM/WP/HOLDCLK/CSDIO DOFigure 2. W25X16, W25X32 and W25X64 Block DiagramW25X16, W25X32, W25X64Publication Release Date: February 26, 2007, Revision E- 11 -10. FUNCTIONAL DESCRIPTION10.1 SPI OPERATIONS10.1.1 SPI ModesThe W25X16/32/64 is accessed through an SPI compatible bus consisting of four signals: Serial Clock (CLK), Chip Select (/CS), Serial Data Input/Output (DIO) and Serial Data Output (DO). Both SPI bus operation Modes 0 (0,0) and 3 (1,1) are supported. The primary difference between Mode 0 and Mode 3 concerns the normal state of the CLK signal when the SPI bus master is in standby and data is not being transferred to the Serial Flash. For Mode 0 the CLK signal is normally low. For Mode 3 the CLK signal is normally high. In either case data input on the DIO pin is sampled on the rising edge of the CLK. Data on the DO and DIO pins are clocked out on the falling edge of CLK.10.1.2 Dual Output SPIThe W25X16/32/64 supports Dual output operation when using the "Fast Read with Dual Output" (3B hex) instruction. This feature allows data to be transferred from the Serial Flash memory at twice the rate possible with the standard SPI. This instruction is ideal for quickly downloading code from Flash to RAM upon power-up (code-shadowing) or for applications that cache code-segments to RAM for execution. The Dual output feature simply allows the SPI input pin to also serve as an output during this instruction. All other operations use the standard SPI interface with single output signal.10.1.3 Hold FunctionThe /HOLD signal allows the W25X16/32/64 operation to be paused while it is actively selected (when /CS is low). The /HOLD function may be useful in cases where the SPI data and clock signals are shared with other devices. For example, consider if the page buffer was only partially written when a priority interrupt requires use of the SPI bus. In this case the /HOLD function can save the state of the instruction and the data in the buffer so programming can resume where it left off once the bus is available again.To initiate a /HOLD condition, the device must be selected with /CS low. A /HOLD condition will activate on the falling edge of the /HOLD signal if the CLK signal is already low. If the CLK is not already low the /HOLD condition will activate after the next falling edge of CLK. The /HOLD condition will terminate on the rising edge of the /HOLD signal if the CLK signal is already low. If the CLK is not already low the /HOLD condition will terminate after the next falling edge of CLK.During a /HOLD condition, the Serial Data Output (DO) is high impedance, and Serial Data Input/Output (DIO) and Serial Clock (CLK) are ignored. The Chip Select (/CS) signal should be kept active (low) for the full duration of the /HOLD operation to avoid resetting the internal logic state of the device.W25X16, W25X32, W25X64- 12 -10.2 WRITE PROTECTIONApplications that use non-volatile memory must take into consideration the possibility of noise and other adverse system conditions that may compromise data integrity. To address this concern the W25X16/32/64 provides several means to protect data from inadvertent writes.10.2.1 Write Protect Features• Device resets when VCC is below threshold. • Time delay write disable after Power-up. • Write enable/disable instructions.• Automatic write disable after program and erase. • Software write protection using Status Register.• Hardware write protection using Status Register and /WP pin.•Write Protection using Power-down instruction.Upon power-up or at power-down the W25X16/32/64 will maintain a reset condition while VCC is below the threshold value of V WI , (See Power-up Timing and Voltage Levels and Figure 20). While reset, all operations are disabled and no instructions are recognized. During power-up and after the VCC voltage exceeds V WI , all program and erase related instructions are further disabled for a time delay of t PUW . This includes the Write Enable, Page Program, Sector Erase, Block Erase, Chip Erase and the Write Status Register instructions. Note that the chip select pin (/CS) must track the VCC supply level at power-up until the VCC-min level and t VSL time delay is reached. If needed a pull-up resister on /CS can be used to accomplish this.After power-up the device is automatically placed in a write-disabled state with the Status Register Write Enable Latch (WEL) set to a 0. A Write Enable instruction must be issued before a Page Program, Sector Erase, Chip Erase or Write Status Register instruction will be accepted. After completing a program, erase or write instruction the Write Enable Latch (WEL) is automatically cleared to a write-disabled state of 0.Software controlled write protection is facilitated using the Write Status Register instruction and setting the Status Register Protect (SRP) and Block Protect (TB, BP2, BP1, and BP0) bits. These Status Register bits allow a portion or all of the memory to be configured as read only. Used in conjunction with the Write Protect (/WP) pin, changes to the Status Register can be enabled or disabled under hardware control. See Status Register for further information.Additionally, the Power-down instruction offers an extra level of write protection as all instructions are ignored except for the Release Power-down instruction.W25X16, W25X32, W25X64Publication Release Date: February 26, 2007, Revision E- 13 -11. CONTROL AND STATUS REGISTERSThe Read Status Register instruction can be used to provide status on the availability of the Flash memory array, if the device is write enabled or disabled, and the state of write protection. The Write Status Register instruction can be used to configure the devices write protection features. See Figure 3.11.1 STATUS REGISTER11.1.1 BUSYBUSY is a read only bit in the status register (S0) that is set to a 1 state when the device is executing a Page Program, Sector Erase, Block Erase, Chip Erase or Write Status Register instruction. During this time the device will ignore further instructions except for the Read Status Register instruction (see t W , t PP , t SE , TBE , and t CE in AC Characteristics). When the program, erase or write status register instruction has completed, the BUSY bit will be cleared to a 0 state indicating the device is ready for further instructions.11.1.2 Write Enable Latch (WEL)Write Enable Latch (WEL) is a read only bit in the status register (S1) that is set to a 1 after executing a Write Enable Instruction. The WEL status bit is cleared to a 0 when the device is write disabled. A write disable state occurs upon power-up or after any of the following instructions: Write Disable, Page Program, Sector Erase, Block Erase, Chip Erase and Write Status Register.11.1.3 Block Protect Bits (BP2, BP1, BP0)The Block Protect Bits (BP2, BP1, and BP0) are non-volatile read/write bits in the status register (S4, S3, and S2) that provide Write Protection control and status. Block Protect bits can be set using the Write Status Register Instruction (see t W in AC characteristics). All, none or a portion of the memory array can be protected from Program and Erase instructions (see Status Register Memory Protection table). The factory default setting for the Block Protection Bits is 0, none of the array protected. The Block Protect bits can not be written to if the Status Register Protect (SRP) bit is set to 1 and the Write Protect (/WP) pin is low.11.1.4 Top/Bottom Block Protect (TB)The Top/Bottom bit (TB) controls if the Block Protect Bits (BP2, BP1, BP0) protect from the Top (TB=0) or the Bottom (TB=1) of the array as shown in the Status Register Memory Protection table. The TB bit is non-volatile and the factory default setting is TB=0. The TB bit can be set with the Write Status Register Instruction provided that the Write Enable instruction has been issued. The TB bit can not be written to if the Status Register Protect (SRP) bit is set to 1 and the Write Protect (/WP) pin is low.11.1.5 Reserved BitsStatus register bit location S6 is reserved for future use. Current devices will read 0 for this bit location. It is recommended to mask out the reserved bit when testing the Status Register. Doing this will ensure compatibility with future devices.W25X16, W25X32, W25X64- 14 -11.1.6 Status Register Protect (SRP)The Status Register Protect (SRP) bit is a non-volatile read/write bit in status register (S7) that can be used in conjunction with the Write Protect (/WP) pin to disable writes to status register. When the SRP bit is set to a 0 state (factory default) the /WP pin has no control over status register. When the SRP pin is set to a 1, the Write Status Register instruction is locked out while the /WP pin is low. When the /WP pin is high the Write Status Register instruction is allowed.Figure 3. Status Register Bit LocationsW25X16, W25X32, W25X64Publication Release Date: February 26, 2007, Revision E- 15 -11.1.7 Status Register Memory ProtectionSTATUS REGISTER (1)W25X64 (64M-BIT) MEMORY PROTECTIONTBBP2BP1BP0BLOCK(S)ADDRESSES DENSITY (KB)PORTIONx 0 0 0 NONE NONE NONE NONE0 0 0 1 126 and 127 7E0000h - 7FFFFFh 1M -bit Upper 1/64 0 0 1 0 124 and 127 7C0000h - 7FFFFFh 2M-bit Upper 1/32 0 0 1 1 120 thru 127 780000h - 7FFFFFh 4M-bit Upper 1/16 0 1 0 0 112 thru 127 700000h - 7FFFFFh 8M-bit Upper 1/8 0 1 0 1 96 thru 127 600000h - 7FFFFFh 16M-bit Upper 1/4 0 1 1 0 64 thru 127 400000h - 7FFFFFh 32M-bit Upper 1/2 1 0 0 1 0 and 1 000000h - 01FFFFh 1M-bit Lower 1/64 1 0 1 0 0 thru 3 000000h - 03FFFFh 2M-bit Lower 1/32 1 0 1 1 0 thru 7 000000h - 07FFFFh 4M-bit Lower 1/16 1 1 0 0 0 thru 15 000000h – 0FFFFFh 8M-bit Lower 1/8 1 1 0 1 0 thru 31 000000h – 1FFFFFh 16M-bit Lower 1/4 1 1 1 0 0 thru 63 000000h – 3FFFFFh 16M-bit Lower 1/2 x 1 1 10 thru 127 000000h - 7FFFFFh 64M-bit ALLSTATUS REGISTER (1)W25X32 (32M-BIT) MEMORY PROTECTIONTBBP2BP1BP0BLOCK(S)ADDRESSES DENSITY(KB)PORTIONx 0 0 0 NONE NONE NONE NONE 0 0 0 1 63 3F0000h - 3FFFFFh 512K-bit Upper 1/64 0 0 1 0 62 and 63 3E0000h - 3FFFFFh 1M-bit Upper 1/32 0 0 1 1 60 thru 63 3C0000h - 3FFFFFh 2M-bit Upper 1/16 0 1 0 0 56 thru 63 380000h - 3FFFFFh 4M-bit Upper 1/8 0 1 0 1 48 thru 63 300000h - 3FFFFFh 8M-bit Upper 1/4 0 1 1 0 32 thru 63 200000h - 3FFFFFh 16M-bitUpper 1/2 1 0 0 1 0 000000h - 00FFFFh 512K-bit Lower 1/64 1 0 1 0 0 and 1 000000h - 01FFFFh 1M-bit Lower 1/32 1 0 1 1 0 thru 3 000000h - 03FFFFh 2M-bit Lower 1/16 1 1 0 0 0 thru 7 000000h - 07FFFFh 4M-bit Lower 1/8 1 1 0 1 0 thru 15 000000h – 0FFFFFh 8M-bit Lower 1/4 1 1 1 0 0 thru 31 000000h – 1FFFFFh 16M-bit Lower 1/2 x 1 1 1 0 thru 63 000000h - 3FFFFFh 32M-bitALLW25X16, W25X32, W25X64- 16 -STATUS REGISTER (1) W25X16 (16M-BIT) MEMORY PROTECTIONTB BP2 BP1 BP0 BLOCK(S) ADDRESSES DENSITY (KB) PORTIONx 0 0 0 NONE NONE NONE NONE 0 0 0 1 31 1F0000h - 1FFFFFh 512K-bit Upper 1/32 0 0 1 0 30 and 31 1E0000h - 1FFFFFh 1M-bit Upper 1/16 0 0 1 1 28 thru 31 1C0000h - 1FFFFFh 2M-bit Upper 1/8 0 1 0 0 24 thru 31 180000h - 1FFFFFh 4M-bit Upper 1/4 0 1 0 1 16 thru 31 100000h - 1FFFFFh 8M-bitUpper 1/2 1 0 0 1 0 000000h - 00FFFFh 512K-bit Lower 1/32 1 0 1 0 0 and 1 000000h - 01FFFFh 1M-bit Lower 1/16 1 0 1 1 0 thru 3 000000h - 03FFFFh 2M-bit Lower 1/8 1 1 0 0 0 thru 7 000000h - 07FFFFh 4M-bit Lower 1/4 1 1 0 1 0 thru 15 000000h - 0FFFFFh 8M-bit Lower 1/2 x 1 1 x 0 thru 31 000000h - 1FFFFFh 16M-bitALLNote:1. x = don’t careW25X16, W25X32, W25X64Publication Release Date:February 26, 2007, Revision E- 17 -11.2 INSTRUCTIONSThe instruction set of the W25X16/32/64 consists of fifteen basic instructions that are fully controlled through the SPI bus (see Instruction Set table). Instructions are initiated with the falling edge of Chip Select (/CS). The first byte of data clocked into the DIO input provides the instruction code. Data on the DIO input is sampled on the rising edge of clock with most significant bit (MSB) first.Instructions vary in length from a single byte to several bytes and may be followed by address bytes, data bytes, dummy bytes (don’t care), and in some cases, a combination. Instructions are completed with the rising edge of edge /CS. Clock relative timing diagrams for each instruction are included in figures 4 through 19. All read instructions can be completed after any clocked bit. However, all instructions that Write, Program or Erase must complete on a byte boundary (CS driven high after a full 8-bits have been clocked) otherwise the instruction will be terminated. This feature further protects the device from inadvertent writes. Additionally, while the memory is being programmed or erased, or when the Status Register is being written, all instructions except for Read Status Register will be ignored until the program or erase cycle has completed.11.2.1 Manufacturer and Device IdentificationMANUFACTURER ID(M7-M0)Winbond Serial Flash EFHDevice ID (ID7-ID0) (ID15-ID0) Instruction ABh, 90h 9Fh W25X16 14h 3015h W25X32 15h 3016h W25X6416h3017h。

STM32开发板(小苗板)资料系列之十六

STM32开发板(小苗板)资料系列之十六

STM32开发板(小苗板)资料系列之十六——SPI来源:第九单片机论坛一SPI简介SPI即串行外围设备接口。

它主要应用在EEPROM、FLASH、实时时钟、A/D 转换器、数字信号处理器和数字信号解码器之间。

SPI是一种高速的、全双工、同步的通信总线,并且在芯片的引脚上只占用4根线。

STM32的SPI可以工作在全双工,单向发送,单向接收模式,可以使用DMA方式操作。

更多的介绍可查看《SMT32参考手册》。

二Flash芯片介绍本实验使用的是W25X16Flash芯片,其容量为16Mbit,即2MB。

W25X16将2MB的容量分为32个块,每个块大小为64KB,每个块又分为16个扇区,每个扇区4KB。

W25X16的擦写周期多达10W次,具有20年的数据保存期限,支持电压为2.7至3.6V。

W25X16支持标准的SPI,还支持双输出的SPI,最大SPI时钟可以到75MHz(双输出时相当于150MHz)。

更多的W25X16的介绍请参看W25X16的DATASHEET(在小苗开发板版块每日更新帖子里有该芯片的手册)。

三实验描述小苗开发板使用的SMT32芯片是STM32F103RBT6,有两个SPI接口。

本实验使用的是SPI1(PA4:SPI1_NSS、PA5:SPI1_SCK、PA6:SPI1_MISO、PA7:SPI1_MOSI),各信号线相应连接到FLASH的CS、CLK、DO和DIO,实现SPI通讯,对FLASH进行读写操作。

本实验功能:获取Flash的ID,得出芯片型号,写入一组数据,然后读出。

实验现象如下图所示,通过串口调试助手查看。

四实验代码分析先前的一些实验没有再重复说明添加头文件的问题,这里再强调一下,每用到一个外设,都需要添加相应的头文件,这是必不可少的。

下面看下主函数。

main.c文件主函数中,26行函数开启了系统时钟;27行函数配置了系统滴答用于延时操作;28行函数配置串口功能用于我们使用串口助手查看实验现象;29行函数初始化与W25X16相连的SPI接口;30函数用于唤醒,对FLASH W25X16进行操作时需要开启,该函数在W25X.C文件中实现。

华邦W25Q16存储器颗粒SPI编程

华邦W25Q16存储器颗粒SPI编程

华邦W25Q16存储器颗粒SPI编程W25X16、W25X32 和W25X64 系列FLASH 存储器可以为用户提供存储解决方案,具有“PCB 板占用空间少”、“引脚数量少”、“功耗低”等特点。

与普通串行FLASH 相比,使用更灵活,性能更出色。

它非常适合做代码下载应用,例如存储声音,文本和数据。

工作电压在 2.7V-3.6V 之间,正常工作状态下电流消耗0.5 毫安,掉电状态下电流消耗 1 微安。

所有的封装都是"节省空间"型的。

W25X16、W25X32 和W25X64 分别有8192、16384 和32768 可编程页,每页256 字节。

用"页编程指令"每次就可以编程256个字节。

用"扇区(sector)擦除指令"每次可以擦除16 页,用“块(block)擦除指令”每次可以擦除256 页,用“整片擦除指令”即可以擦除整个芯片。

W25X16、W25X32 和W25X64 分别有512、1024 和2048 个可擦除"扇区"或32、64 和128 个可擦除“块”。

W25X16、W25X32 和W25X64 支持标准的SPI 接口,传输速率最大75MHz。

四线制:①:串行时钟引脚CLK;①:芯片选择引脚CS;①:串行数据输出引脚DO;①:串行数据输入输出引脚DIO。

(注意:第①引脚“串行数据输入输出引脚DIO”的解释:在普通情况下,这根引脚是“串行输入引脚(DI),当使用了快读双输出指令(Fast Read Dual Output instruction)时,这根引脚就变成了DO 引脚,这种情况下,芯片就有了两个DO 引脚了,所以叫做双输出,这时,如果与芯片通信的速率相当于翻了一倍,所以传输速度更快。

)另外,芯片还具有保持引脚(HOLD)、写保护引脚(WP)、可编程写保护位(位于状态寄存器bit1)、顶部和底部块的控制等特征,使得控制芯片更具灵活性。

W25X16SPIFlash数据手册.

W25X16SPIFlash数据手册.

W25X16 AND W25X32Publication Release Date: February 13, 2006 - 1 -Revision A16M-BIT AND 32M-BITSERIAL FLASH MEMORY WITH4KB SECTORS AND DUAL OUTPUT SPI W25X16 AND W25X32- 2 -Table of Contents-1. GENERAL DESCRIPTION (4)2. FEATURES........................................................................................................................... (4)3. PIN CONFIGURATION 208-MIL (5)4. PIN DESCRIPTION 208-MIL (5)5. PIN CONFIGURATION 300-MIL (6)6.PIN DESCRIPTION 300-MIL......................................................................................................6 6.1 Package Types...............................................................................................................7 6.2 Chip Select (/CS............................................................................................................7 6.3 Serial Data Output (DO.................................................................................................7 6.4 Write Protect (/WP.........................................................................................................7 6.5 HOLD (/HOLD (7)6.6 Serial Clock (CLK..........................................................................................................7 6.7 Serial Data Input / Output (DIO. (77. BLOCK DIAGRAM......................................................................................................................8 8.FUNCTIONALDESCRIPTION ...................................................................................................9 8.1SPI OPERATIONS (98.1.1 SPI Modes........................................................................................................................9 8.1.2 Dual Output SPI (9)8.1.3Hold Function...................................................................................................................9 8.2 WRITE PROTECTION.. (108.2.1Write Protect Features (109.CONTROL AND STATUS REGISTERS...................................................................................11 9.1STATUS REGISTER (119.1.1BUSY (11)9.1.2 Write Enable Latch (WEL..............................................................................................11 9.1.3 Block Protect Bits (BP2, BP1, BP0................................................................................11 9.1.4Top/Bottom Block Protect (TB (11)9.1.5 Reserved Bits.................................................................................................................11 9.1.6 Status Register Protect (SRP........................................................................................12 9.1.7Status Register Memory Protection................................................................................13 9.2 INSTRUCTIONS.. (149.2.1 Manufacturer and Device Identification..........................................................................14 9.2.2 Instruction Set(1(159.2.3 Write Disable(04h.........................................................................................................16 9.2.4 Write Enable (06h.........................................................................................................16 9.2.5Read Status Register (05h (17W25X16 AND W25X32Publication Release Date: February 13, 2006- 3 -Revision A9.2.6 Write Status Register(01h............................................................................................18 9.2.7 Read Data(03h.............................................................................................................19 9.2.8 Fast Read (0Bh.............................................................................................................20 9.2.9 Fast Read Dual Output (3Bh.. (21)9.2.10 Page Program(02h.....................................................................................................22 9.2.11 Sector Erase (20h.......................................................................................................23 9.2.12 Block Erase (D8h.. (24)9.2.13 Chip Erase(C7h..........................................................................................................25 9.2.14 Power-down (B9h........................................................................................................26 9.2.15 Release Power-down / Device ID (ABh.. (27)9.2.16 Read Manufacturer / Device ID(90h...........................................................................29 9.2.17JEDEC ID (9Fh (3010.ELECTRICAL CHARACTERISTICS.........................................................................................31 10.1 Absolute Maximum Ratings (1 (31)10.2 Operating Ranges.........................................................................................................31 10.3 Endurance and Data Retention (31)10.4 Power-up Timing and Write Inhibit Threshold..............................................................32 10.5 DC Electrical Characteristics (Preliminary(1..............................................................33 10.6 AC Measurement Conditions........................................................................................34 10.7 AC ElectricalCharacteristics........................................................................................35 10.8 AC Electrical Characteristics (cont’d...........................................................................36 10.9Serial Output Timing (3710.10 Input Timing..................................................................................................................37 10.11 Hold Timing.................................................................................................................37 11.PACKAGE SPECIFICATION....................................................................................................38 11.1 8-Pin SOIC 208-mil (Package Code SS. (38)11.2 8-Pin SOIC 300-mil (Package Code SF. (3912. ORDERINGINFORMATION ....................................................................................................40 13.REVISION HISTORY (41W25X16 AND W25X32- 4 -1. GENERAL DESCRIPTIONThe W25X16 (16M-bit and W25X32 (32M-bit Serial Flash memories provide a storage solution for systems with limited space, pins and power. The 25X series offers flexibility and performance well beyond ordinary Serial Flash devices. They are ideal for code download applications as well as storing voice, text and data. The devices operateon a single 2.7V to 3.6V power supply with current consumption as low as 5mA active and 1µA for power-down. All devices are offered in space-saving packages.The W25X16/32 array is organized into 8192/16384 programmable pages of 256-bytes each. Up to 256 bytes can be programmed at a time using the Page Program instruction. Pages can be erased in groups of 16 (sector erase, groups of 256 (block erase or the entire chip (chip erase. The W25X16/32 has 512/1024 erasable sectors and 32/64 erasable blocks respectively. The small 4KB sectors allow for greater flexibility in applications that require data and parameter storage. (See figure 2.The W25X16/32 support the standard Serial Peripheral Interface (SPI, and a high performance dual output SPI using four pins: Serial Clock, Chip Select, Serial Data I/O and Serial Data Out. SPI clock frequencies of up to 75MHz are supported allowing equivalent clock rates of 150MHz when using the Fast Read Dual Output instruction. These transfer rates are comparable to those of 8 and 16-bit Parallel Flash memories.A Hold pin, Write Protect pin and programmable write protect, with top or bottom array control features, provide further control flexibility. Additionally, the device supports JEDEC standard manufacturer and device identification.2. FEATURES• Family of Serial Flash Memories– W25X16: 16M-bit / 2M -byte (2,097,152 – W25X32: 32M-bit / 4M-byte(4,194,304 – 256-bytes per programmable page– Uniform 4K-byte Sectors / 64K-byte Blocks • SPI with Single or Dual Outputs– Clock, Chip Select, Data I/O, Data Out – Optional Hold function for SPI flexibility • Data Transfer up to 150MHz – Clock operation to 75MHz– Fast Read Dual Output instruction – Auto-increment Read capability• Flexable Architecture with 4KB sectors – Sector Erase (4K-bytes – Block Erase (64K-byte– Page program up to 256 bytes <2ms – Up to 100,000 erase/write cycles – 20-year retention• Low Power Consumption, Wid e Temperature Range – Single 2.7 to 3.6V supply– 5mA active current, 1µA Power-down (typ – -40° to +85°C operating range• Software and Hardware Write Protection – Write-Protect all or portion of memory – Enable/Disable protection with /WP pin – Top or bottom array protection• Space Efficient Packaging – 8-pin SOIC 208-mil (W25X16– 16-pin SOIC 300-mil (W25X16 & W25X32W25X16 AND W25X32Publication Release Date: February 13, 2006- 5 -Revision A3.PIN CONFIGURATION 208-MILFigure 1a 。

Flash ROM ST25P16中文资料

Flash ROM ST25P16中文资料
时防止被意外读、写、擦除指令改变.
状态寄存器:
■ 状态寄存器包含大量状态和控制位,它可读出和写入通过特殊的指令重新设置. ■ WIP Bit:写进程位显示闪存器是否忙于写状态寄存器、编程、或擦除. ■ WEL Bit:写使能锁位显示内部写使能位状态. ■ BP2,BP1,BP0 bit.块保护位是不稳定的,它们是定义软件的保护区域,防止补编程指令和擦除改变. ■ SRWD bit.状态寄存器写取消位(SRWD)是和写保护信号(W) 一起操作的.状态寄存器写取消位和写保护信号可以使设备进
时: ◇ 上电重启 ◇ 写取消指令(WRDI)完成 ◇ 写状态寄存器指令(WRSR)完成 ◇ 页编程指令(PP)完成 ◇ 段擦除指令(SE)完成 ◇ 片擦除指令(BE)完成
■ 块保护位(BP2,BP1,BP0)可设置闪存器部分区域只能被读,不能写入,这就是软件保护模式(SPM) ■ 写保护信号(W)允许块保护位(BP2,BP1,BP0)和状太寄存器写保护位(SRWD)位被保护.这就是硬件保护模式(HPM). ■ 除低功耗之外,掉电模式提供了额外软件保护,此时所有的写入,编程,擦除指令都不被处理.
态寄存器处活动状态,同时闪存器也处于待命模式(而不是睡眠模式).当此信号为低是闪存器被选此时闪存器处于活动工作 状态. 上电后片选端需有一个下降沿信号优先于其它起动信号. ■ HOLD:锁定信号用于暂停通信而不用取消片选信号.在锁定条件下,串行输出端处高阻抗,串行输入(D)上的数据和是钟 信号不进行处理. 起动锁定的条件是片选信号(S)必需为低电平. ■ Write Protect(W).这个输入信号主要作用是冻结被状态寄存器(BP2,BP1,BP0)设置区域, 防止被意外编程和擦除.
PDF 文件使用 "pdfFactory Pro" 试用版本创建

【STM8】外挂存储器W25Q16

【STM8】外挂存储器W25Q16

【STM8】外挂存储器W25Q16好像有⼏张图⽚被强制缩⼩了?看到这篇博客的⼈先对你们说声抱歉,我不知道怎么设置⽂字就可以很长(⽂章宽度的全部),图⽚就只有⽂章宽度的2/3宽度开新分页应该就是原始尺⼨了,这点还是和⼤家说抱歉。

⽂章⾥⾯提到的页编程,就是写数据了,因为这是英⽂直译的结果(PageProgram)为了测试这个外挂Flash存储器,我在淘宝买了⼀个⼩板,3元不到其实也可以直接买芯⽚回来⾃⼰接,反正没⼏个元件这个芯⽚是⽤SPI通讯的我找不到没⽔印的图⽚,暂时先⽤W25Q128的不过他俩板⼦长得⼀模⼀样,元件也⼀样。

除了芯⽚型号板⼦上的LED和电阻串联,上电后LED就亮,没别的意思电容是滤波⽤的,它紧靠芯⽚的VCC引脚另外附上两个链接,这是我之前写的博客,是关于『STM8开发环境』和『STM8 - SPI通讯』,这篇博客的测试基础,是建⽴在STM8上的关于如何接线,SPI通讯这篇博客有提到,如果有需要可以观看SPI相关知识有了,就可以开始了开始之前,还是先介绍⼀下⼤纲【W25Q16芯⽚介绍】:芯⽚命名规则、芯⽚引脚图、引脚功能介绍【W25Q16指令】:官⽅定义的指令,还有时序图介绍【W25Q16初步测试】:执⾏其中⼀个指令(读取芯⽚ID),看看执⾏的效果,以此确认步骤是否正确,如果这⼀步都不正确,就不⽤谈最主要的读和写吧?【W25Q16状态寄存器】:寄存器的⼀些状态,例如芯⽚是不是在忙、是不是处于保护状态、保护的区域、是否可写状态。

等等【W25Q16读、写、擦除】:读、写、擦除相关代码【W25Q16芯⽚介绍】应该很好理解,像W25Q02系列,就是2G的Flash,下⽅的红字也提醒了,这是2G bit,像我们下载的电影、⾳乐,这些都是byte为单位的,设计的时候要考虑⼀下提取码:iq4jW25Q16的引脚如下统⼀说明:前⽅有斜线的/,例如/CS,这个斜线代表低电平使能【/CS】:⽚选引脚,低电平呢芯⽚⼯作,⾼电平芯⽚就罢⼯,当然,别想着⼀劳永逸这种事,直接把它接GND,我就吃到苦头了,这引脚请务必接GPIO【DO】:数据输出【/WP】:写保护,低电平呢只能读,⾼电平就随你读写【GND】:接地【DI】:数据输⼊(接收外来的指令)【CLK】:时钟【/HOLD】:数据暂停控制,低电平代表暂停,⾼电平⼯作,通常⽤于多个设备共享⼀个SPI,如果只有⼀主⼀从,可以把这引脚接VCC 【VCC】:2.7~3.6V另外,这个芯⽚可以⽀持『双输出』和『四输出』,可以提升读数据的速度具体的⽅法是把其他引脚的功能都改为输出(IO1、2、3、4)就好⽐⼤家的车速都⼀样,道路有两条的情况下,⼀定⽐只有⼀条道路,处理车流量来的快在引脚图的上⽅,有芯⽚的介绍,其中会看到104MHz、208MHz、416MHz分别是SPI单输出、双输出和四输出遗憾的是STM8的SPI,最快也只有10MHz左右,想要处理双输出和四输出,是不可能的不过对于我的项⽬来说,这已经⾜够了【W25Q16指令】下⾯介绍写使能的时序图,但是在『W25Q16初步测试』的环节中,会读取JEDEC ID(指令发送0x9F),最终看看W25Q16有没有反馈『⽣产商ID』和『芯⽚ID』给我给下降沿的原因,在介绍引脚图时,⽚选引脚/CS已经说明了,下达每个指令之前,必须给下降沿DI,也就是W25Q16接收的数据,0x06,⽂章往上拉找到指令的图⽚,找对应的位置,0x06就是写使能DO,因为这个指令不需要反馈数据给主机,所以是⾼阻态【W25Q16初步测试】我是透过Uart来打印数据的,图⽚左上有⽰意图⽤⽰意图上的1234来表⽰流程,就是『1 234 234 234 234 234 234 234 234 234 234』234出现了⼗次,因为在『SPI接收中断』⾥⾯,判断count < 10除了第⼀个『2』是指令(0x9F)以外,后⾯所有的『2』全部都是伪字节(0xFE),这是为了制造时钟给从机,在我另⼀篇博客有提到下⾯贴上完整代码,另外附上链接,需要代码的朋友也可以下载提取码:4pbw#include"iostm8s103F3.h"#include "W25Qxx.h"typedef unsigned char u8;typedef unsigned short int u16;typedef unsigned int u32;void UART1_sendchar(unsigned char c);void SPI_sendchar(unsigned char c);u8 count = 0;/* ====================================== *//* ============ 【Uart】init ============ *//* ====================================== */void Init_UART1(void){UART1_CR1 = 0x00;UART1_CR2 = 0x00;UART1_CR3 = 0x00;// 设置波特率,必须注意以下⼏点:// (1) 必须先写BRR2// (2) BRR1存放的是分频系数的第11位到第4位,// (3) BRR2存放的是分频系数的第15位到第12位,和第3位// 到第0位// 例如对于波特率位9600时,分频系数=2000000/9600=208// 对应的⼗六进制数为00D0,BBR1=0D,BBR2=00UART1_BRR2 = 0x00;UART1_BRR1 = 0x0d;UART1_CR2 = 0x2c; // 允许接收,发送,开接收中断}/* ====================================== *//* =========== 【Uart】发送函数 ========= *//* ====================================== */void UART1_sendchar(unsigned char c){while((UART1_SR & 0x80) == 0x00); // 等待发送缓冲区为空UART1_DR = c;}/* ====================================== *//* =========== 【Uart】接收中断 ========= *//* ====================================== */#pragma vector= UART1_R_OR_vector//0x19__interrupt void UART1_R_OR_IRQHandler(void){PC_ODR_ODR4 = 0; // 串⼝收到数据后进⼊中断,先给W25Qxx下降沿,等等透过SPI发送指令SPI_sendchar(UART1_DR); // 发送SPI数据(UART接收到什么就发什么),然后等待SPI中断,实现⾃发⾃收}/* ====================================== *//* ============ 【SPI】init ============= *//* ====================================== */void Init_SPI(void){CLK_PCKENR1 |= 0x02; //打开SPI时钟/*PC6、PC5设置为输出,最⼤10MHz*///PC_DDR = 0x60; // ⽤下⽅⽐较详细的写法//PC_CR1 = 0xe0; // ⽤下⽅⽐较详细的写法//PC_CR2 = 0x60; // ⽤下⽅⽐较详细的写法PC_DDR_DDR4 = 1; // 配置PC4(/CS)端⼝为输出模式PC_CR1_C14 = 1; // 配置PC4(/CS)端⼝为推挽输出模式PC_CR2_C24 = 1; // 配置PC4(/CS)端⼝为⾼速率输出PC_DDR_DDR5 = 1; // 配置PC5(SCK)端⼝为输出模式PC_CR1_C15 = 1; // 配置PC5(SCK)端⼝为推挽输出模式PC_CR2_C25 = 1; // 配置PC5(SCK)端⼝为⾼速率输出PC_DDR_DDR6 = 1; // 配置PC6(MOSI)端⼝为输出模式PC_CR1_C16 = 1; // 配置PC6(MOSI)端⼝为推挽输出模式PC_CR2_C26 = 1; // 配置PC6(MOSI)端⼝为⾼速率输出PC_DDR_DDR7 = 0; // 配置PC7(MISO)端⼝为输⼊模式PC_CR1_C17 = 1; // 配置PC7(MISO)端⼝为弱上拉输⼊模式PC_CR2_C27 = 0; // 禁⽌PC7(MISO)端⼝外部中断SPI_ICR_RXIE = 1; // 开启SPI中断接收// [7]先发MSB// [6]禁⽌SPI// [5][4][3]f_Master / 2// [2]主设备// [1]空闲时SCK保持低电平// [0]数据采样从第⼀个时钟沿开始SPI_CR1 = 0x04; /*MSB、1MHz、主设备、CPOL空闲为低、CPHA第⼀个时钟开始*/// [7]双线单向模式// [6]输⼊使能(只接收模式)// [5]CRC计算禁⽌// [4]下个发送数据来⾃Tx缓冲// [3]保留// [2]全双⼯(同时收发)// [1]使能软件从设备管理(不需要判断硬件CS位,节省⼀个引脚)// [0]主模式SPI_CR2 = 0x03; /*双线单向视距传输、CRC计算禁⽌、软件NSS、主模式*/SPI_CR1_SPE = 1; // 打开SPI}/* ====================================== *//* =========== 【SPI】发送函数 ========== *//* ====================================== */void SPI_sendchar(unsigned char c){while(!(SPI_SR & 0x02)); // 等待发送缓冲区为空SPI_DR = c; // 将发送的数据写到数据寄存器//while(!(SPI_SR & 0x01)); // 等待接收缓冲区⾮空,这是轮询的⽅式,但是我想在中断来处理//UART1_sendchar(SPI_DR);}/* ====================================== *//* =========== 【SPI】接收中断 ========== *//* ====================================== */#pragma vector=SPI_RXNE_vector__interrupt void SPI_RXNE_IRQHandler(void){//RxBuf[cnt++]=SPI_DR;while(!(SPI_SR & 0x01));UART1_sendchar(SPI_DR); // 把SPI接收到的数据,透过UART,传回给USB转TTL⼩板count++;if(count < 10) SPI_sendchar(0xfe); // 发送伪字节else{count = 0;PC_ODR_ODR4 = 1; // 重新置为⾼电平,等待下⼀次的指令}}/* ====================================== *//* ============== 【Main】 ============== *//* ====================================== */main(){Init_UART1();Init_SPI();PC_ODR_ODR4 = 1; // 初始上电给⾼电平,后续W25Qxx在执⾏指令前,再给下降沿asm("rim"); // 开中断,sim为关中断while (1);}【W25Q16状态寄存器】⽂章有点长,再说明⼀个寄存器就好了先上⼀张图,这是状态寄存器⾥的内容下⾯是寄存器内各个『位』的说明,另外『R』代表『只可读』,『W』代表『只可写』,『RW』代表『可读可写』【BUSY】(R):芯⽚在忙的时候,状态=1,不忙时=0,什么时候在忙呢?执⾏『页编程』『任何⼀种擦除』『写状态』都是,芯⽚忙完这些事会⾃动清0【WEL】(R):『写保护』位,执⾏写使能后,由芯⽚⾃动置1,芯⽚处于『写保护』时该位=0,写禁⽤状态发⽣在『通电时』『写禁⽌』『页编程』『任何⼀种擦除』和『写状态寄存器』【BP0、1、2】(RW):这三位决定了需要保护的区域,例如⼀些固件,你不想后续被修改的东西,都可以保护。

16路入16出可编程场效应管可编程说明书

16路入16出可编程场效应管可编程说明书

八入八出场效应管工控开发板说明书第一部分:八入八出场效应管工控开发板功能介绍1.八入八出场效应管工控开发板简介2.硬件连接使用说明3.STC12C5A60S2单片机简介4.N沟道Irf1205场效应管简介第二部分:板子编程入门教学1. Keil uVision42.用keil软件建一个简单工程3.开发板下载程序方法第三部分:板子各种软件应用实例一、基础类1.控制某一路延时通断实例2.随机输出控制使用实例3.八路输出流水灯实例4.一对一输入输出互锁控制实例5.一对一输入输出自锁控制实例6.一对一输入输出点动控制实例7.电脑采集输入控制输出实例二、提高类1.掉电记忆应用实例2.加密设定次数应用实例附录:1、硬件原理图第一部分:八入八出场效应管工控开发板功能介绍1.八入八出场效应管工控开发板简介●尺寸:115mmX77mmX25MM●供电:板子供电直流6到40V●八路数字量输入光耦(PC817)隔离●八路场效应管输出带光耦(PC817)隔离●拓展口八个io●输入输出带指示●晶振11.0592Mhz●场效应管(IRF1205)输出可控制55V44A负载功能:八个输入可以接八个NPN型传感器,或者控制设备的限位开关、启动、停止开关等等,可以实现任意控制设备的编程(仿西门子s7-200开关管型),可以控制直流12V到55V,107w负载2.硬件连接标注说明●整版标注:●485连接注:RS485建议采用双绞线连接,采用带屏蔽的双绞线连接,并将屏蔽层接地,总线上挂多个模块时,采用手拉手不的连接方式。

●采集外部干接点开关量信号的接法●输出控制负载连接3.STC12C5A60S2系列1T单片机简介STC12C5A60S2/AD/PWM系列单片机是宏晶科技生产的单时钟/机器周期(1T)的单片机,是高速/低功耗/超强抗干扰的新一代8051单片机,指令代码完全兼容传统8051,但速度快8-12倍。

内部集成MAX810专用复位电路,2路PWM,8路高速10位A/D转换(250K/S),针对电机控制,强干扰场合。

IARFORSTM8例程要点总结计划

IARFORSTM8例程要点总结计划

IAR+STM8 ——EXTI外面中断控制寄存器2013-03-2123:23:15| 分类:STM8|举报|字号订阅这块三合一的开发板上有且只有一个按键,没方法,就拿这唯一的按键来用吧。

吸取前面UART3的教训,先看开发板的原理图吧。

这个按键被接到了STM8S207SB的PD7上,已做了上拉办理。

为了简单了然,还是点LED1吧。

按一下LED1亮,再按一下LED1灭。

好了,写程序吧。

include<iostm8s207sb.h>#defineLED1_FLASHPD_ODR_ODR3=!PD_ODR_ODR3//开发板上的LED1接在PD3上voidGPIO_init(void){PD_DDR=0x08;//配置PD端口的方向寄存器PD3输出PD_CR1=0x08;//设置PD3为推挽输出PD_CR2=0x80;//使能PD7外面中断}voidEXTI_init(void){EXTI_CR1=0x80;//PD口下降沿触发中断}#pragmavector=0x02//这里很要点!看下面说明。

__interruptvoidEXTI_PD7_TLI(void){LED1_FLASH;}voidinit_devices(void){asm("sim");//关全局中断GPIO_init();EXTI_init();asm("rim");//开全局中断}voidmain(void){init_devices();主循环里没有程序需要执行while(1);}这里重视要说明的一点是PD7的外面中断程序。

看了一下芯片手册,PD口外面中断EXTI3的中断向量号是6,想自然,又是想自然,按IAR的规矩中断向量要加2,就这样写#pragmavector=0x08,结果就是按下按键,程序没响应了,素来在中断里不出来。

接下来只能另想方法,仔细翻了资料后发现,PD7和PD其他端口不同样,PD7后边拖了个小尾巴TLI,再看手册上的TLI描述,乖乖,TLI拥有芯片最高等别中断,享有独立专用的中断向量号0,这下就好办了,按IAR的规矩,向量号加2,程序改成#pragmavector=0x02,重新来一遍编译、下载、运行,按键终于听话了。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档