www.久久久久|狼友网站av天堂|精品国产无码a片|一级av色欲av|91在线播放视频|亚洲无码主播在线|国产精品草久在线|明星AV网站在线|污污内射久久一区|婷婷综合视频网站

當前位置:首頁 > 單片機 > 單片機
[導(dǎo)讀]Norflash型號為sst39vf32#ifndef __NORFLASH_H_#define __NORFLASH_H_#include "common.h"#include "delay.h"#include "debugserial.h"#define NOR_FLASH_BASE 0x80000000#define NOR_FLASH_SIZE 0x00100000#define

Norflash型號為sst39vf32

#ifndef __NORFLASH_H_

#define __NORFLASH_H_

#include "common.h"

#include "delay.h"

#include "debugserial.h"

#define NOR_FLASH_BASE 0x80000000

#define NOR_FLASH_SIZE 0x00100000

#define GET_ADDR(addr) (volatile uint16_t *)(NOR_FLASH_BASE | (addr<<1))

#define SECTOR_SIZE 0x800 /* Must be 2048 words for 39VF160 */

#define BLOCK_SIZE 0x8000 /* Must be 32K words for 39VF160 */

#define SST_ID 0xBF /* SST Manufacturer's ID code */

#define SST_39VF160 0x235D /* SST 39VF160 device code */

#define PROGRAM_TIMEOUT 0x00008000

//norflash 初始化必須在sram初始化之前

void norflash_init(void);

void norflash_erase(void);

u32 norflash_check_id(void);

u32 norflash_write_word(u32 add,u16 data);

u32 norflash_toggle_bit_check(u32 addr,u16 data);

#endif

#include "norflash.h"

static void norflash_io_init(void)

{

//a0-a22

/* init EMC_A1 */

LPC_IOCON->P4_1=0x21;

/* init EMC_A2 */

LPC_IOCON->P4_2=0x21;

/* init EMC_A3 */

LPC_IOCON->P4_3=0x21;

/* init EMC_A4 */

LPC_IOCON->P4_4=0x21;

/* init EMC_A5 */

LPC_IOCON->P4_5=0x21;

/* init EMC_A6 */

LPC_IOCON->P4_6=0x21;

/* init EMC_A7 */

LPC_IOCON->P4_7=0x21;

/* init EMC_A8 */

LPC_IOCON->P4_8=0x21;

/* init EMC_A9 */

LPC_IOCON->P4_9=0x21;

/* init EMC_A10 */

LPC_IOCON->P4_10=0x21;

/* init EMC_A11 */

LPC_IOCON->P4_11=0x21;

/* init EMC_A12 */

LPC_IOCON->P4_12=0x21;

/* init EMC_A13 */

LPC_IOCON->P4_13=0x21;

/* init EMC_A14 */

LPC_IOCON->P4_14=0x21;

/* init EMC_A15 */

LPC_IOCON->P4_15=0x21;

/* init EMC_A16 */

LPC_IOCON->P4_16=0x21;

/* init EMC_A17 */

LPC_IOCON->P4_17=0x21;

/* init EMC_A18 */

LPC_IOCON->P4_18=0x21;

/* init EMC_A19 */

LPC_IOCON->P4_19=0x21;

/* init EMC_A20 */

LPC_IOCON->P4_20=0x21;

/* init EMC_A21 */

LPC_IOCON->P4_21=0x21;

/* init EMC_A22 */

LPC_IOCON->P4_22=0x21;

//d0-d15

/* init EMC_D0 */

LPC_IOCON->P3_0=0x21;

/* init EMC_D1 */

LPC_IOCON->P3_1=0x21;

/* init EMC_D2 */

LPC_IOCON->P3_2=0x21;

/* init EMC_D3 */

LPC_IOCON->P3_3=0x21;

/* init EMC_D4 */

LPC_IOCON->P3_4=0x21;

/* init EMC_D5 */

LPC_IOCON->P3_5=0x21;

/* init EMC_D6 */

LPC_IOCON->P3_6=0x21;

/* init EMC_D7 */

LPC_IOCON->P3_7=0x21;

/* init EMC_D8 */

LPC_IOCON->P3_8=0x21;

/* init EMC_D9 */

LPC_IOCON->P3_9=0x21;

/* init EMC_D10 */

LPC_IOCON->P3_10=0x21;

/* init EMC_D11 */

LPC_IOCON->P3_11=0x21;

/* init EMC_D12 */

LPC_IOCON->P3_12=0x21;

/* init EMC_D13 */

LPC_IOCON->P3_13=0x21;

/* init EMC_D14 */

LPC_IOCON->P3_14=0x21;

/* init EMC_D15 */

LPC_IOCON->P3_15=0x21;

/* init EMC_WE */

LPC_IOCON->P4_25=0x21;

/* init EMC_oe */

LPC_IOCON->P4_24=0x21;

/* init EMC_cs0 */

LPC_IOCON->P4_30=0x21;

}

void norflash_init(void)

{

LPC_SC->SCS|=(1<<0);//emc地址不移位

//打開emc時鐘與端口時鐘

LPC_SC->PCONP|=(1<<15)|(1<<11);//打開時鐘

LPC_SC->EMCDLYCTL=0x00001010;//延時時間初始化

LPC_EMC->Control=0x00000001;//emc使能

LPC_EMC->Config=0x00000000;//emc配置清零,小端模式

norflash_io_init();

DelayMs(100);

LPC_EMC->StaticConfig0&=~(3<<0); //

LPC_EMC->StaticConfig0|=(1<<0); //設(shè)置總線寬度16位

LPC_EMC->StaticConfig0|=(1<<7); //設(shè)置讀寫有效電平,讀為低電平

LPC_EMC->StaticWaitWen0&=~(7<<0);

LPC_EMC->StaticWaitWen0|=(2<<0);//設(shè)置片選到寫使能的延時時間

LPC_EMC->StaticWaitOen0&=~(7<<0);

LPC_EMC->StaticWaitOen0|=(2<<0);//設(shè)置片選到輸出使能的延時

LPC_EMC->StaticWaitWr0&=~(0x1f<<0);

LPC_EMC->StaticWaitWr0|=(0x1f<<0);//設(shè)置片選到寫入的延時

LPC_EMC->StaticWaitPage0&=~(0x1f<<0);

LPC_EMC->StaticWaitPage0|=(0x1f<<0);//設(shè)置讀模式順序存取延時

LPC_EMC->StaticWaitRd0&=~(0x1f<<0);

LPC_EMC->StaticWaitRd0|=(0x1f<<0);//設(shè)置片選到讀取的延時

LPC_EMC->StaticWaitTurn0&=~(0x1f<<0);

LPC_EMC->StaticWaitTurn0|=(0x1f<<0);//設(shè)置總線周轉(zhuǎn)周期

DelayMs(100);

}

void norflash_erase(void)

{

volatile uint16_t*ip;

ip=GET_ADDR(0x5555);

*ip=0x00AA;

ip=GET_ADDR(0x2AAA);

*ip=0x0055;

ip=GET_ADDR(0x5555);

*ip=0x0080;

ip=GET_ADDR(0x5555);

*ip=0x00AA;

ip=GET_ADDR(0x2AAA);

*ip=0x0055;

ip=GET_ADDR(0x5555);

*ip=0x0010;

DelayMs(10); /* Use timer 1 */

return;

}

//檢查nand id

u32 norflash_check_id(void)

{

volatile uint16_t*ip;

uint16_t SST_id1,SST_id2;

/* Issue the Software Product ID code to 39VF160 */

ip=GET_ADDR(0x5555);

*ip=0x00AA;

ip=GET_ADDR(0x2AAA);

*ip=0x0055;

ip=GET_ADDR(0x5555);

*ip=0x0090;

DelayMs(10);

/* Read the product ID from 39VF160 */

ip=GET_ADDR(0x0000);

SST_id1=*ip&0x00FF;

ip=GET_ADDR(0x0001);

SST_id2=*ip;

/* Issue the Soffware Product ID Exit code thus returning the 39VF160 */

/* to the read operating mode */

ip=GET_ADDR(0x5555);

*ip=0x00AA;

ip=GET_ADDR(0x2AAA);

*ip=0x0055;

ip=GET_ADDR(0x5555);

*ip=0x00F0;

DelayMs(10);

/* Check ID */

if((SST_id1==SST_ID)&&(SST_id2==SST_39VF160))

{

return(0);

}

else

{

printf("SST_id1 = %x rn",SST_id1);

p

本站聲明: 本文章由作者或相關(guān)機構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

Sept. 10, 2025 ---- 根據(jù)TrendForce集邦咨詢最新發(fā)布的《全球電動車逆變器市場數(shù)據(jù)》,2025年第二季受惠純電動車(BEV)銷售成長,全球電動車(注1)牽引逆變器裝機量達766萬臺,年增19%。...

關(guān)鍵字: 增程式電動車 SiC 牽引逆變器

Sept. 8, 2025 ---- 根據(jù)TrendForce集邦咨詢最新調(diào)查,2025年第二季NVIDIA(英偉達) Blackwell平臺規(guī)?;鲐?,以及北美CSP業(yè)者持續(xù)擴大布局General Server(通用型...

關(guān)鍵字: SSD DDR4 服務(wù)器

Sept. 4, 2025 ---- Apple(蘋果)即將發(fā)布iPhone 17、iPhone 17 Air(暫名)、iPhone 17 Pro及Pro Max四款旗艦新機,除了外觀辨識度升級,處理器性能、散熱和拍攝功...

關(guān)鍵字: iPhone 16 A19處理器 折疊機

Sept. 3, 2025 ---- 根據(jù)TrendForce集邦咨詢最新發(fā)布的《2025近眼顯示市場趨勢與技術(shù)分析》報告,2025年隨著國際品牌陸續(xù)推出AR眼鏡原型,以及Meta預(yù)計在近期發(fā)布AR眼鏡Celeste,市...

關(guān)鍵字: AR眼鏡 OLED

Sept. 2, 2025 ---- TrendForce集邦咨詢表示,2025年第二季DRAM產(chǎn)業(yè)因一般型DRAM (Conventional DRAM)合約價上漲、出貨量顯著增長,加上HBM出貨規(guī)模擴張,整體營收為3...

關(guān)鍵字: DRAM 智能手機 ASP

Sept. 1, 2025 ---- 根據(jù)TrendForce集邦咨詢最新調(diào)查,2025年第二季因中國市場消費補貼引發(fā)的提前備貨效應(yīng),以及下半年智能手機、筆電/PC、Server新品所需帶動,整體晶圓代工產(chǎn)能利用率與出貨...

關(guān)鍵字: 晶圓代工 智能手機 筆電

Aug. 28, 2025 ---- 根據(jù)TrendForce集邦咨詢最新調(diào)查,2025年第二季NAND Flash產(chǎn)業(yè)雖面臨平均銷售價格(ASP)小幅下滑,所幸原廠減產(chǎn)策略緩解供需失衡,疊加中、美兩大市場政策推動,整體...

關(guān)鍵字: NAND Flash SSD AI

Aug. 26, 2025 ---- NVIDIA(英偉達)近日推出的Jetson Thor被視為機器人的物理智慧核心,以Blackwell GPU、128 GB記憶體堆疊出2070 FP4 TFLOPS AI算力,是前...

關(guān)鍵字: 機器人 大型語言模型 AI算力

Aug. 21, 2025 ---- 根據(jù)TrendForce集邦咨詢最新液冷產(chǎn)業(yè)研究,隨著NVIDIA GB200 NVL72機柜式服務(wù)器于2025年放量出貨,云端業(yè)者加速升級AI數(shù)據(jù)中心架構(gòu),促使液冷技術(shù)從早期試點邁...

關(guān)鍵字: AI 數(shù)據(jù)中心 服務(wù)器

除了充電電路外,鋰電池的放電過程也需要保護。鋰電池的放電電壓不能低于3.0V,否則電池壽命會大幅縮短。為了實現(xiàn)這一保護,工程師們設(shè)計了DW01芯片與8205 MOS管的電路組合。DW01芯片能夠監(jiān)控鋰電池的放電電壓和電流...

關(guān)鍵字: 鋰電池 電池
關(guān)閉