STM32单片机用FSMC接口控制SRAM
STM32单片机用FSMC接口控制SRAM
本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明.
环境:
主机:WIN7
开发环境:MDK4.72
MCU:STM32F103ZE
说明:
sram型号:IS62WV51216BLL
连接方式:FSMC
大小:1M字节.512K * 16
源代码:
inf_sram.h
/********************************************************************** 无线定位基站程序* 主文件*(c)copyright 2013,jdh* All Right Reserved*文件名:main.c*程序员:jdh**********************************************************************//**********************************************************************头文件**********************************************************************/#include "public.h"uint8_t test_sram[100] __attribute__((at(Bank1_SRAM2_ADDR)));/**********************************************************************函数**********************************************************************/int main(void){uint8_t i = 0;uint16_t buf1[3] = {1,2,3};uint16_t buf2[10] = {0};//初始化设备init_device();#ifndef DEBUG//打开内部看门狗inf_enable_iwdg();#endif//sram测试代码//FSMC_SRAM_WriteHalfWord(0,1);//FSMC_SRAM_WriteHalfWord(2,2);//FSMC_SRAM_WriteHalfWord(4,3);//Test_Data = FSMC_SRAM_ReadHalfWord(2);//FSMC_SRAM_WriteBuffer(buf1,0,3);//FSMC_SRAM_ReadBuffer(buf2,0,3);test_sram[0] = 5;test_sram[1] = 2;test_sram[2] = 3;FSMC_SRAM_ReadBuffer(buf2,0,10);__nop();//状态机执行while (1){for (i = 0;i < 6;i++){//inf_set_led(i + 1,LED_ON);inf_delay_ms(10);//inf_set_led(i + 1,LED_OFF);inf_delay_ms(10);}}}#ifdef USE_FULL_ASSERT/** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */void assert_failed(uint8_t* file, uint32_t line){ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { }}#endif