你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【STM32F429开发日志】2. 外部sdram读写测试  

[复制链接]
caizhiwei 提问时间:2014-5-28 11:53 /


硬件平台:STM32F429I-DISCORVERY
软件平台:KEIL MDK5.10
作者   :羊村长

知识点:标准的SDRAM一般都是4个BANK,stm32f429-diso开发板使用的是IS42S16400J这个芯片。
IS42S16400J也有4个Bank,总容量为1Mbitx 16-bit x 4-bank = 67,108,864 bits = 64-Mbit ,每个BANK的组成
4096rows x 256 columns x 16 bits(=16Mbit), 对应的外部引线是12行8列,请参看datasheet.

实验目的:由于TM32F429I-DISCORVERY扩展了sdram,这对于视频播放,图片解码,音频解码,usb大容量数据缓冲
是非常有利的!

实验结果:
1.8Bit 测试成功率为100%,16Bit测试成功率为100%

#define IS42S16400J_SIZE     0x400000   // 4M x 16Bit(存储宽度)=16Mbit(每个Bank的容量)

int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured,
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
  */  
        
        uint8_t ubWritedata_8b = 0x3C, ubReaddata_8b = 0;  
  uint16_t uhWritedata_16b = 0x1E5A, uhReaddata_16b = 0;  
  uint32_t uwReadwritestatus = 0;
  uint32_t counter = 0x0;
        
  SysTick_Init();
  STM_EVAL_LED_Config();
  STM_EVAL_PBInit(BUTTON_MODE_EXTI);
        
  /* Initialize the LCD */
  LCD_Init();
  LCD_LayerInit();
  LTDC_Cmd(ENABLE);
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  LCD_Clear(LCD_COLOR_BLUE);
         
  /* Disable write protection */
  FMC_SDRAMWriteProtectionConfig(FMC_Bank2_SDRAM,DISABLE);
        

  while (1)
  {
               
                /*********************** 8-bits AHB transaction test ************************/   
                /* Wait for User button to be pressed */
                while (STM_EVAL_PBGetState() != Bit_SET)
                {}
                STM_EVAL_LEDOff(LED3);
                STM_EVAL_LEDOff(LED4);
                /* Wait for User button is released */
                while (STM_EVAL_PBGetState() != Bit_RESET)
                {}
        
                /* Erase SDRAM memory */
                for (counter = 0x00; counter < IS42S16400J_SIZE; counter++)
                {
                        *(__IO uint8_t*) (SDRAM_BANK_ADDR + counter) = (uint8_t)0x0;
                }
               
                /* Write data value to all SDRAM memory */
                for (counter = 0; counter < IS42S16400J_SIZE; counter++)
                {
                        *(__IO uint8_t*) (SDRAM_BANK_ADDR + counter) = (uint8_t)(ubWritedata_8b + counter);
                }
               
                /* Read back SDRAM memory and check content correctness*/
                counter = 0;
                uwReadwritestatus = 0;
                while ((counter < IS42S16400J_SIZE) && (uwReadwritestatus == 0))
                {
                        ubReaddata_8b = *(__IO uint8_t*)(SDRAM_BANK_ADDR + counter);
                        if ( ubReaddata_8b != (uint8_t)(ubWritedata_8b + counter))
                        {
                                uwReadwritestatus = 1;                                                
                        }
                        counter++;
                }
          if(uwReadwritestatus == 0)
                {
                          STM_EVAL_LEDOn(LED3);
                                STM_EVAL_LEDOff(LED4);
                                LCD_Clear(LCD_COLOR_GREEN);
                                LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"  8-bits AHB    ");
                                LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"  Transaction   ");
                                LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *)"  Test-> OK     ");         
                }
                else
                {
                    STM_EVAL_LEDOn(LED4);
                                STM_EVAL_LEDOff(LED3);
                                LCD_Clear(LCD_COLOR_RED);
                                LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"    8-bits AHB   ");
                                LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"   Transaction   ");
                                LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *)"   Test-> Failed ");         
                }
               
                /*********************** 16-bits AHB transaction test ***********************/   
                /* Wait for User button to be pressed */
                while (STM_EVAL_PBGetState() != Bit_SET)
                {}
                                /* Turn Off Leds */   
                STM_EVAL_LEDOff(LED3);
                STM_EVAL_LEDOff(LED4);
               
                /* Wait for User button is released */
                while (STM_EVAL_PBGetState() != Bit_RESET)
                {}
               
        
                /* Erase SDRAM memory */
                for (counter = 0x00; counter < IS42S16400J_SIZE; counter++)
                {
                        *(__IO uint16_t*) (SDRAM_BANK_ADDR + 2*counter) = (uint16_t)0x00;
                }
               
                /* Write data value to all SDRAM memory */
                for (counter = 0; counter < IS42S16400J_SIZE; counter++)
                {
                        *(__IO uint16_t*) (SDRAM_BANK_ADDR + 2*counter) = (uint16_t)(uhWritedata_16b + counter);
                }
               
                /* Read back SDRAM memory and check content correctness*/
                counter = 0;
                uwReadwritestatus = 0;
                while ((counter < IS42S16400J_SIZE) && (uwReadwritestatus == 0))
                {
                        uhReaddata_16b = *(__IO uint16_t*)(SDRAM_BANK_ADDR + 2*counter);
                        if ( uhReaddata_16b != (uint16_t)(uhWritedata_16b + counter))
                        {
                                uwReadwritestatus = 1;                        
                        }
                        counter++;
                }
                if(uwReadwritestatus == 0)
                {
                        STM_EVAL_LEDOn(LED3);
                        STM_EVAL_LEDOff(LED4);
                        LCD_Clear(LCD_COLOR_GREEN);
                        LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"  16-bits AHB   ");
                        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"  Transaction   ");
                        LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *)"  Test-> OK     ");   
                }
                else
                {
                        STM_EVAL_LEDOn(LED4);
                        STM_EVAL_LEDOff(LED3);
                        LCD_Clear(LCD_COLOR_RED);
                        LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"  16-bits AHB    ");
                        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)" Transaction     ");
                        LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *)" Test-> Failed   ");     
                }        
  }
}
16Bit数据测试:
IMG_20140528_111757.jpg

8Bit数据测试:
IMG_20140528_111751.jpg
工程代码:
3.SDRAM读写.zip (1.59 MB, 下载次数: 1126)
收藏 5 评论60 发布时间:2014-5-28 11:53

举报

60个回答
q1478963 回答时间:2014-11-20 11:01:13
王建 发表于 2014-6-19 10:06
16位数据访问,难道不是counter < (IS42S16400J_SIZE/2)吗?不怕访问溢出?

counter值应该是指可写16bit总数目,如果是读写一个字节8bit,可用总数量是counter*2,你可以试试

*(__IO uint8_t*) (SDRAM_BANK_ADDR + 2*counter-1) = (uint8_t)(ubWritedata_8b + counter);

ubReaddata_8b = *(__IO uint8_t*)(SDRAM_BANK_ADDR + 2*counter-1);
如果不减1,那就溢出了。
bruce-409962 回答时间:2015-7-16 11:33:36

#define IS42S16400J_SIZE     0x400000   // 4M x 16Bit(存储宽度)=16Mbit(每个Bank的容量)
请问上面的注释对吗?
caizhiwei 回答时间:2015-1-6 15:45:59
hzrobin 发表于 2014-5-29 09:24
羊村长,弱弱问下,“SDRAM在视频播放,图片解码,音频解码,usb大容量数据缓冲比较有用”,能简单说个用法 ...

可以的,比如摄像头就需要FIFO,图片解码也需要大量ram的
caizhiwei 回答时间:2014-5-28 11:53:52

RE:【STM32F429开发日志】2. 外部sdram读写测试

沙发自己坐
沐紫 回答时间:2014-5-28 12:47:25

RE:【STM32F429开发日志】2. 外部sdram读写测试

二楼我来抢,哈哈,多谢楼主
hzrobin 回答时间:2014-5-29 09:24:45

RE:【STM32F429开发日志】2. 外部sdram读写测试

羊村长,弱弱问下,“SDRAM在视频播放,图片解码,音频解码,usb大容量数据缓冲比较有用”,能简单说个用法例子,简单提个思路就可以
MrJiu 回答时间:2014-5-29 09:58:41

RE:【STM32F429开发日志】2. 外部sdram读写测试

支持一下..........
wjandsq 回答时间:2014-6-1 20:52:15

RE:【STM32F429开发日志】2. 外部sdram读写测试

应该搞分散加载,变量自动定位在外部sdram中,毕竟大数据处理时变量不可能总是搬来搬去。
mon51 回答时间:2014-6-2 22:23:31

RE:【STM32F429开发日志】2. 外部sdram读写测试

好东西,请问如何接2片?
abcdotaabc 回答时间:2014-6-16 16:46:14

回复:【STM32F429开发日志】2. 外部sdram读写测试

 32位数据怎么处理
wjandsq 回答时间:2014-6-19 10:06:12

RE:【STM32F429开发日志】2. 外部sdram读写测试

16位数据访问,难道不是counter &lt; (IS42S16400J_SIZE/2)吗?不怕访问溢出?
友情牵绊-2046836 回答时间:2014-6-24 18:01:46

回复:【STM32F429开发日志】2. 外部sdram读写测试

 参考参考!!!
快乐汉 回答时间:2014-6-24 20:56:55

回复:【STM32F429开发日志】2. 外部sdram读写测试

学习中,谢谢分享!
一纸荒凉~~~ 回答时间:2014-7-2 09:50:20

回复:【STM32F429开发日志】2. 外部sdram读写测试

学习学习
黄毛 回答时间:2014-7-9 19:46:18

回复:【STM32F429开发日志】2. 外部sdram读写测试

 支持
libenyan 回答时间:2014-7-21 16:53:47

回复:【STM32F429开发日志】2. 外部sdram读写测试

很好,我需要测试下;
wyc 回答时间:2014-7-22 17:23:40

RE:【STM32F429开发日志】2. 外部sdram读写测试

学习学习
12345下一页
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版