找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 4894|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

PIC18讀取SD卡示例PIC18 SD BMP Reader源碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:373 發(fā)表于 2017-12-19 10:32 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
很久之前學(xué)習(xí)PIC的時(shí)候找的資料,對(duì)讀寫(xiě)SD卡很有幫助。!

實(shí)物圖:


仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機(jī)源程序如下:
  1. /***************************************************

  2. PIC18F SD/MMC Bitmap File Reader
  3. May 2010

  4. *****************************************************/
  5. #include <htc.h>
  6. #include <string.h>

  7. #define _XTAL_FREQ 48000000

  8. #pragma config FOSC     = HSPLL_HS
  9. #pragma config PLLDIV   = 5                                // (20 MHz crystal on PICDEM FS USB board)
  10. #pragma config CPUDIV   = OSC1_PLL2                // Clock source from 96MHz PLL/2

  11. #pragma config PWRT = ON
  12. #pragma config BOR = ON
  13. #pragma config BORV = 2
  14. #pragma config WDT = OFF
  15. #pragma config DEBUG = ON
  16. #pragma config LVP = OFF

  17. #define TRUE 1
  18. #define FALSE 0
  19. #include "pff.h"
  20. #include "lcd3310.h"
  21. #include "lcd_bmp.h"

  22. FATFS Fs;                        /* File system object */
  23. DIR Dir;                        /* Directory object */
  24. FILINFO Fno;                /* File information */

  25. void delay(void);

  26. void main(void)
  27. {
  28.         BYTE res, i;

  29.         while(1){
  30.                 delay();
  31.                 lcd_init();
  32.                 lcd_clear();
  33.                 lcd_text(0,1, "PIC BMP Reader");
  34.                 lcd_text(0,3, "insert SDcard!");
  35.                 if (pf_mount(&Fs) ) continue;        /* Initialize FS */
  36.                 lcd_text(0,3, " initialized ");
  37.                 delay();
  38.                 delay();
  39.                 while(1){
  40.                         if (pf_opendir(&Dir, "")) break;                                // open root directory
  41.                         while (!pf_readdir(&Dir, &Fno) && Fno.fname[0]) {
  42.                                 if( strstr(Fno.fname, ".BMP") ){                        // BMP file
  43.                                         if(pf_open(Fno.fname)) continue;                // open file
  44.                                         draw_bitmap(Fno.fname);

  45.                                         delay();
  46.                                         delay();
  47.                                         delay();
  48.                                 }

  49.                                
  50.                         }
  51. ……………………

  52. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
PIC18-SD-BMP-Reader.rar (1.03 MB, 下載次數(shù): 48)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表