caizhiwei 发表于 2014-5-28 11:53:54

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



硬件平台: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数据测试:


8Bit数据测试:

工程代码:

caizhiwei 发表于 2014-5-28 11:53:52

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

:lol:lol沙发自己坐

沐紫 发表于 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读写测试

支持一下..........:L:L

王建 发表于 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位数据怎么处理

王建 发表于 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读写测试

 参考参考!!!
页: [1] 2 3 4 5 6 7
查看完整版本: 【STM32F429开发日志】2. 外部sdram读写测试