我是靠谱客的博主 大气咖啡豆,最近开发中收集的这篇文章主要介绍基于ADuC845的数据采集板➤ 01数据采集➤ 02模块设计➤ ※ 结论,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

作者:卓晴博士,清华大学自动化系
更新时间:2020-10-31 Saturday
 

 

01数据采集


数据采集,并进行FLASH存储在很多应用中都非常有用:

  • 测试电池的放电过程;
  • 采集环境缓变的数据;

创界uVision下的ADuC845的工程文件液晶12864COG 液晶模块串口/并口ST7565R带背3.3v 12864-14显示屏 测试了具有24bit-ADC的MCU,基于该款MCU,外加 M25P64 64MBit串口Flash存储器,可以形成数据采集和存储模块。

 

02模块设计


1.电路板设计1

▲ 数据采集存储板

▲ 数据采集存储板

▲ 快速制版PCB

▲ 快速制版PCB

2.软件设计2

▲ 数据采集板上的下载程序

▲ 数据采集板上的下载程序

对于M25P64的读写协议是从M25P80改装回来。
对于M25P80的相关历程在之前的FreescaleMC9S12E256SanMingSCCE256-SmartCar改装过来。

/*
**==============================================================================
** M25P64.H:            -- by Dr. ZhuoQing, 2020-10-31
**
**  Description:
**
**==============================================================================
*/
#ifndef __M25P64__
#define __M25P64__
//------------------------------------------------------------------------------
#ifdef M25P64_GLOBALS
   #define M25P64_EXT
#else
   #define M25P64_EXT extern
#endif // M25P64_GLOBALS
//------------------------------------------------------------------------------
//==============================================================================
sbit M25P64_CS          = P2^3;

//------------------------------------------------------------------------------

void M25P64Init(void);

//==============================================================================
//                    PORTABLE MACRODEFINTION
//------------------------------------------------------------------------------
// Configration SPI port in Device initialize function:
//          BAUD : < 20Mhz
//       MODE : 0,3 : Input sample is sample on rising edge of clock. The data
//                    is output on the falling edge of clk.
//       BYTE : Significant bit is transfer out first.
//------------------------------------------------------------------------------
#define M25P64_CS_ON                M25P64_CS = 1
#define M25P64_CS_OFF               M25P64_CS = 0
#define M25P64_HOLD_ON            
#define M25P64_HOLD_OFF            
#define M25P64_WP_ON            
#define M25P64_WP_OFF            

void M25P64Nop(unsigned int nCount);
#define M25P64_DELAY_MS             M25P64Nop(446)

void M25P64DelayMS(unsigned int nms);

#define M25P64_SECTOR_LENGTH            0x10000
#define M25P64_SECTOR_NUMBER            0x128
#define M25P64_PAGE_LENGTH              0x100
#define M25P64_PAGE_NUMBER              0x8000

//==============================================================================
//                    COMMAND MACRO DEFINITION
//------------------------------------------------------------------------------
#define M25P64_WREN                  0x06        // Write Enable
#define M25P64_WRDI                  0x04        // Write Disable
#define M25P64_RDSR                  0x05        // Read Status Register
#define M25P64_WRSR                  0x01        // Write Status Register
#define M25P64_READ                  0x03        // Read Data Bytes
#define M25P64_FAST_READ             0x0b        // Read Data Bytes at Higer Speed
#define M25P64_PP                    0x02        // Page Program
#define M25P64_SE                    0xd8        // Sector Erase
#define M25P64_BE                    0xc7        // Bulk Erase
#define M25P64_DP                    0xb9        // Deep Power-down
#define M25P64_RES                   0xab        // Release from Deep Power-down
#define M25P64_RDID                  0x9f        // Read Identification
                                        
//------------------------------------------------------------------------------
#define M25P64_STATUS_SRWD           0x80        // Status register Write Protect    
#define M25P64_STATUS_BP2            0x10        // Block Protect Bits
#define M25P64_STATUS_BP1            0x08        // 
#define M25P64_STATUS_BP0            0x04        //
#define M25P64_STATUS_WEL            0x02        // Write Enable Latch 
#define M25P64_STATUS_WIP            0x01        // Write in Progress Bit                                           

//------------------------------------------------------------------------------
//                    SUBFUNCTIONS
void M25P64WriteEnable(void);
void M25P64WriteDisable(void);

void M25P64WriteStatus(unsigned char ucStatus);
unsigned char M25P64ReadStatus(void);

#define M25P64_POLL_WAIT            0xfffffffe
unsigned long M25P64WaitPoll(void);

void M25P64ReadBytes(unsigned long lnAddress, unsigned char * pBuffer, unsigned int nLength);
unsigned char M25P64ReadByte(unsigned long lnAddress);
void M25P64ReadBytesFast(unsigned long lnAddress, unsigned char * pBuffer, unsigned int nLength);

void M25P64ProgramPage(unsigned long lnAddress, unsigned char * pBuffer, unsigned char ucLength);
void M25P64EraseSector(unsigned long lnAddress);
void M25P64EraseBulk(void);

void M25P64DeepPowerdown(void);
unsigned char M25P64Reset(void);

unsigned long M25P64ReadSignatureID(void);

#define M25P64_SIGN                0x202017     // M25P64 signature is 0x16

//==============================================================================
//             END OF THE FILE : M25P64.H
//------------------------------------------------------------------------------
#endif // __M25P64__
/*
**==============================================================================
** M25P64.C:             -- by Dr. ZhuoQing, 2020-10-31
**
**==============================================================================
*/
#include <ADUC845.h>
#include <stdio.h>
#include <intrins.h>
#include "uc845.h"

//------------------------------------------------------------------------------
#define M25P64_GLOBALS        1              // Define the global variables
#include "M25P64.H"

//------------------------------------------------------------------------------
void M25P64Nop(unsigned int nTime) {
    while(nTime --) {
        _nop_();
    }

}

void M25P64DelayMS(unsigned int nms) {
    unsigned int i;
    for(i = 0; i < nms; i ++)
        M25P64_DELAY_MS;
}

void M25P64Init(void) {
    M25P64_CS_ON;
    M25P64_HOLD_ON;
    M25P64_WP_ON;
    M25P64WriteStatus(0x00);                     // Disable BPL0,1,2
}

//------------------------------------------------------------------------------
//                    SUBFUNCTIONS
void M25P64WriteEnable(void) {
    M25P64_CS_OFF;
    SPISendReceive(M25P64_WREN);
    M25P64_CS_ON;
}    

//------------------------------------------------------------------------------
void M25P64WriteDisable(void) {
    M25P64_CS_OFF;
    SPISendReceive(M25P64_WRDI);
    M25P64_CS_ON;
}

//------------------------------------------------------------------------------
void M25P64WriteStatus(unsigned char ucStatus) {
    M25P64_CS_OFF;
    SPISendReceive(M25P64_WRSR);
    SPISendReceive(ucStatus);
    M25P64_CS_ON;
}

//------------------------------------------------------------------------------
unsigned char M25P64ReadStatus(void) {
    unsigned char ucReturn;
    M25P64_CS_OFF;
    SPISendReceive(M25P64_RDSR);
    ucReturn = SPISendReceive(0x0);
    M25P64_CS_ON;
    return ucReturn;
}

//------------------------------------------------------------------------------
unsigned long M25P64WaitPoll(void) {
    unsigned long i;
    unsigned char ucStatus;
    for(i = 0; i < M25P64_POLL_WAIT; i ++) {
        ucStatus = M25P64ReadStatus();
        if((ucStatus & M25P64_STATUS_WIP) == 0) return i;
    }
    return i;
}

//------------------------------------------------------------------------------
void M25P64ReadBytes(unsigned long lnAddress, unsigned char * pBuffer, unsigned int nLength) {
    unsigned int i;
    unsigned char ucData;
    
    M25P64_CS_OFF;
    SPISendReceive(M25P64_READ);
    
    ucData = (unsigned char)(lnAddress >> 16);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress >> 8);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress);
    SPISendReceive(ucData);    
    
    for(i = 0; i < nLength; i ++) *(pBuffer ++) = SPISendReceive(0x0);
    M25P64_CS_ON;
}

//------------------------------------------------------------------------------
unsigned char M25P64ReadByte(unsigned long lnAddress) {
    unsigned char ucByte;
    unsigned char ucData;
    
    M25P64_CS_OFF;
    SPISendReceive(M25P64_READ);
    
    ucData = (unsigned char)(lnAddress >> 16);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress >> 8);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress);
    SPISendReceive(ucData);    
    
    ucByte = SPISendReceive(0x0);
    M25P64_CS_ON;
    return ucByte;
}

//------------------------------------------------------------------------------
void M25P64ReadBytesFast(unsigned long lnAddress, unsigned char * pBuffer, unsigned int nLength) {
    unsigned int i;
    unsigned char ucData;
    
    M25P64_CS_OFF;
    SPISendReceive(M25P64_FAST_READ);
    
    ucData = (unsigned char)(lnAddress >> 16);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress >> 8);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress);
    SPISendReceive(ucData);    
    SPISendReceive(0x0);
    
    for(i = 0; i < nLength; i ++) *(pBuffer ++) = SPISendReceive(0x0);
    
    M25P64_CS_ON;
}

//------------------------------------------------------------------------------
void M25P64ProgramPage(unsigned long lnAddress, unsigned char * pBuffer, unsigned char ucLength) {
    unsigned char ucData;
    
    M25P64WriteEnable();
    M25P64_CS_OFF;
    SPISendReceive(M25P64_PP);
    
    ucData = (unsigned char)(lnAddress >> 16);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress >> 8);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress);
    SPISendReceive(ucData);    
    
    do {
        SPISendReceive(*(pBuffer ++));
    } while(--ucLength);
    
    M25P64_CS_ON;
}

//------------------------------------------------------------------------------
void M25P64EraseSector(unsigned long lnAddress) {
    unsigned char ucData;
    
    M25P64WriteEnable();
    M25P64_CS_OFF;
    
    SPISendReceive(M25P64_SE);
    ucData = (unsigned char)(lnAddress >> 16);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress >> 8);
    SPISendReceive(ucData);
    ucData = (unsigned char)(lnAddress);
    SPISendReceive(ucData);    
    
    M25P64_CS_ON;
}

//------------------------------------------------------------------------------
void M25P64EraseBulk(void) {
    M25P64WriteEnable();
    M25P64_CS_OFF;
    SPISendReceive(M25P64_BE);
    M25P64_CS_ON;
}

//------------------------------------------------------------------------------
void M25P64DeepPowerdown(void) {
    M25P64_CS_OFF;
    SPISendReceive(M25P64_DP);
    M25P64_CS_ON;
}

//------------------------------------------------------------------------------
unsigned char M25P64Reset(void) {
    unsigned char ucReturn;
    M25P64_CS_OFF;
    SPISendReceive(M25P64_RES);
    SPISendReceive(0x0);
    SPISendReceive(0x0);
    SPISendReceive(0x0);
    
    ucReturn = SPISendReceive(0x0);
    M25P64_CS_ON;
    return ucReturn;
}

//------------------------------------------------------------------------------
unsigned long M25P64ReadSignatureID(void) {
    unsigned char ucReturn;
    unsigned long lnNumber;
    
    M25P64_CS_OFF;
    SPISendReceive(M25P64_RDID);
    ucReturn = SPISendReceive(0x0);
    lnNumber = ucReturn;
    ucReturn = SPISendReceive(0x0);
    lnNumber = (lnNumber << 8) + ucReturn;
    ucReturn = SPISendReceive(0x0);
    lnNumber = (lnNumber << 8) + ucReturn;
    
    M25P64_CS_ON;
    return lnNumber;
    
}

//==============================================================================
//                END OF THE FILE : M25P64.C
//------------------------------------------------------------------------------

 

※ 结论


基于ADuC845设计了举办ADDC输出的采集板。配置有M25P64存储相应的采集数据。存储空间为8Mbytes.

■ 相关文献链接:

  • 创界uVision下的ADuC845的工程文件
  • 液晶12864COG 液晶模块串口/并口ST7565R带背3.3v 12864-14显示屏
  • M25P64

  1. 基于ADuC845的数据采集工程文件:ADTest2020ADuC84525P64ADuC84525P64.SchDoc ↩︎

  2. 数据采集C51工程文件:C51ADuC845Test2020TestLCDTestLCD.uvproj ↩︎

最后

以上就是大气咖啡豆为你收集整理的基于ADuC845的数据采集板➤ 01数据采集➤ 02模块设计➤ ※ 结论的全部内容,希望文章能够帮你解决基于ADuC845的数据采集板➤ 01数据采集➤ 02模块设计➤ ※ 结论所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(55)

评论列表共有 0 条评论

立即
投稿
返回
顶部