|
发表于 2021-3-3 13:28:22
|
显示全部楼层
SDRAM的初始化参考函数如下,SRAM工程师建议你把中断向量压缩到512字节,从0x20000000+512开始写入你的函数,代码尽量小,你自己测试保证你的函数在JLINK的驱动下能否正常就行。QSPI在评估板的资料包里有两种库函数,一种用DMA的,一种是用寄存器的,并有参考例程,你看方便用哪种方式使能都行。
- void SDRAMinit(void)
- {
- *((volatile unsigned int*)(0xd0000014)) = 0x70000000; //select memory base address
- *((volatile unsigned int*)(0xd0000084)) = 0x00000000; //not remap register
- *((volatile unsigned int*)(0xd0000004)) &= ~((0x01<<26) | (0x03));
- *((volatile unsigned int*)(0xd0000004)) |= 0x02;
- *((volatile unsigned int*)(0xd0000000)) &= (~( (0x01<<14)|(0x01<<12)|(0x01<<7) |(0x01<<5)|(0x01<<4)));
- *((volatile unsigned int*)(0xd0000000)) |= ( (0x01<<13)|(0x01<<11)|(0x01<<10)|(0x07<<9)|(0x01<<8)|(0x01<<6)|(0x01<<3) ); //configuer addr_width and data_width
- *((volatile unsigned int*)(0xd0000054)) &= (~( (0x01<<7)|(0x01<<6)|(0x01<<5)|(0x01<<4)|(0x01<<2)|(0x01<<1)|(0x01<<0) ));
- *((volatile unsigned int*)(0xd0000054)) |= ( (0x01<<3) ); //memory size
- *((volatile unsigned int*)(0xd00000ac)) = 0x32; //fixed value
- *((volatile unsigned int*)(0xd0000010)) = 250; //取值范围为7500/时钟周期 7500/125*2偏小值
- *((volatile unsigned int*)(0xd000000c)) &= (~( (0x01<<8)|(0x01<<7)|(0x01<<6)|(0x01<<3)));
- *((volatile unsigned int*)(0xd000000c)) |= ( (0x01<<6)|(0x01<<0));
- while(1)
- {
- if((*((volatile unsigned int*)(0xd000000c))&0x01)==0) //check SDRAM Controller initialization sequence is complete
- break;
- }
- }
复制代码 |
|