#include <reg52.h> #include <absacc.h> #define uchar unsigned char #define uint unsigned int #include "SPI.H"
void main (void) { uchar SendArray[10]={0x55,0xAA,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09}; uchar GetArray[10]; while (1) { /***在写数据之前,写命令FM33XX_WREN()去激活WEL位。****/ FM33XX_WREN(); FM33XX_Write( 0x0000,10, SendArray); FM33XX_Read( 0x0000,10, GetArray );
/***这是写不成功的范例,因为在写数据之前,没有激活WEL位。****/ SendArray[0] = 0xF0; FM33XX_Write( 0x0000,1, SendArray); FM33XX_Read( 0x0000,1, GetArray ); /***因此这个0xaa实际上是没有写到芯片中的,观察GetArray可知****/
/***读状态寄存器*********************************************/ FM33XX_WREN(); GetArray[0] = FM33XX_RDSR(); //读回来应该是0x42 FM33XX_WRDI(); GetArray[0] = FM33XX_RDSR(); //读回来应该是0x40
/***写数据到串行数据区******************************/ SendArray[0] = 0xAA; SendArray[1] = 0x0F; FM33XX_WREN(); FM33XX_WRPC(0x10,0x02,SendArray); FM33XX_RDPC(0x10,0x02,GetArray); } } |