初级会员

- 积分
- 119
- 金钱
- 119
- 注册时间
- 2014-10-19
- 在线时间
- 2 小时
|

楼主 |
发表于 2015-5-12 19:43:25
|
显示全部楼层
这是main函数 #include "delay.h"
#include "sys.h"
#include "usart.h"
#include "MMC_SD.h"
#include "ff.h"
#include "timer.h"
#include "led.h"
FRESULT res;//??????????·?????
int a,flag;
int t;
FIL fsrc;
FATFS fs;
UINT br,bw;
BYTE buffer[512];
BYTE textFileBuffer[512];
int main(void)
{
uart_init(9600);
NVIC_Configuration();
delay_init(); //???±??????????
LED_Init();
TIM3_Int_Init(1999,7199);//10Khz??????????????????2000??200ms
f_mount(&fs,"0:",1); //????SD?¨
res=f_open(&fsrc,"0:shuju.TXT",FA_CREATE_NEW|FA_WRITE);
if(res==FR_OK)
{
res=f_write(&fsrc, textFileBuffer,sizeof( textFileBuffer),&bw);
printf("/r/n???????¨????/n");
f_close(&fsrc);
}
else if(res==FR_EXIST)
{
printf("\r\n????????????\n");
}
res = f_open(&fsrc, "0:shuju.TXT", FA_OPEN_EXISTING | FA_READ);
br=1;
a=0;
for(;;)
{
for(a=0;a<512;a++)
buffer[a]=0;
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
printf("\r\n %s",buffer);
if(res||br==0) break;
}
f_close(&fsrc);
}
这是串口的
/* void USART1_IRQHandler(void) //????1????·??????ò
{
int i;
for(i=0;i<512;i++)
{
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //????????(????????????????????????
{
TIM_ITConfig(TIM3,TIM_IT_Update ,DISABLE);
res =USART_ReceiveData(USART1);//(USART1->DR); //????????????????
delay_ms(1000);
textFileBuffer=res;
//USART_SendData(USART1,usart_buffer);
TIM_ITConfig(TIM3,TIM_IT_Update ,ENABLE);
}
}
}*/ |
|