51

来自「51读写SD卡」· 代码 · 共 30 行

TXT
30
字号
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sfr AUXR =0x8e;
//pin脚定义
//SD卡使用SPI模式进行读写
//CS  ->P2.2
//MOSI->P2.3
//CLK ->P2.4
//MISO->P2.6

sbit CS =P2^2;
sbit SI =P2^3;
sbit SCK=P2^4;
sbit SO =P2^6;

#define CS_SD_EN    (CS=0)      //为低时表示片选
#define CS_SD_DIS   (CS=1)      //disable     
#define SCK_SD_LOW  (SCK=0)     //low
#define SCK_SD_HIGH (SCK=1)     // SCK = 1
#define SI_SD_LOW   (SI=0)      //(SI,SO均相对SSD)
#define SI_SD_HIGH  (SI=1)      //SI=1

uchar publicdata[100];
uchar Timeout;
uchar cou;
uchar act;
uchar DelayTime=10;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?