最近调试STM32H750的FMC总线与FPGA通信的时候发现了一个问题,使用NE1和FPGA通信可以正常读写,而NE2通道却不能正常写数据,使用示波器观察发现NE2的波形有问题,但是查看代码又看不出来哪里有问题,使用了hal库和寄存器配置都不能解决,有没有大神帮小弟一把,不胜感激。
数据位D0-D15
地址为 A16-23
代码配置如下
void SRAM_init(void)
{
RCC->AHB4ENR |= 2 << 1; //使能C
RCC->AHB4ENR |= 3 << 3; //使能PD,PE
RCC->AHB3ENR |= 1 << 12; //使能FMC时钟
GPIO_Set(GPIOC, PIN8, GPIO_MODE_AF, GPIO_OTYPE_PP, GPIO_SPEED_HIGH, GPIO_PUPD_PU);
GPIO_Set(GPIOD, (0xFFB3), GPIO_MODE_AF, GPIO_OTYPE_PP, GPIO_SPEED_HIGH, GPIO_PUPD_PU);
GPIO_Set(GPIOE, (0XFFFC), GPIO_MODE_AF, GPIO_OTYPE_PP, GPIO_SPEED_HIGH, GPIO_PUPD_PU);
GPIO_AF_Set(GPIOD, 0, 12);
GPIO_AF_Set(GPIOD, 1, 12);
GPIO_AF_Set(GPIOD, 4, 12);
GPIO_AF_Set(GPIOD, 5, 12);
GPIO_AF_Set(GPIOD, 7, 12);
GPIO_AF_Set(GPIOD, 8, 12);
GPIO_AF_Set(GPIOD, 9, 12);
GPIO_AF_Set(GPIOD, 10, 12);
GPIO_AF_Set(GPIOD, 11, 12);
GPIO_AF_Set(GPIOD, 12, 12);
GPIO_AF_Set(GPIOD, 13, 12);
GPIO_AF_Set(GPIOD, 14, 12);
GPIO_AF_Set(GPIOD, 15, 12);
GPIO_AF_Set(GPIOE, 2, 12);
GPIO_AF_Set(GPIOE, 3, 12);
GPIO_AF_Set(GPIOE, 4, 12);
GPIO_AF_Set(GPIOE, 5, 12);
GPIO_AF_Set(GPIOE, 6, 12);
GPIO_AF_Set(GPIOE, 7, 12);
GPIO_AF_Set(GPIOE, 8, 12);
GPIO_AF_Set(GPIOE, 9, 12);
GPIO_AF_Set(GPIOE, 10, 12);
GPIO_AF_Set(GPIOE, 11, 12);
GPIO_AF_Set(GPIOE, 12, 12);
GPIO_AF_Set(GPIOE, 13, 12);
GPIO_AF_Set(GPIOE, 14, 12);
GPIO_AF_Set(GPIOE, 15, 12);
GPIO_AF_Set(GPIOC, 8, 9);
FMC_Bank1->BTCR[0] = 0X00000000;
FMC_Bank1->BTCR[1] = 0X00000000;
FMC_Bank1E->BWTR[0] = 0X00000000;
FMC_Bank1->BTCR[0] |= 1 << 12;
FMC_Bank1->BTCR[0] |= 1 << 14;
FMC_Bank1->BTCR[0] |= 1 << 4;
FMC_Bank1->BTCR[1] |= 0 << 28;
FMC_Bank1->BTCR[1] |= 4 << 0;
FMC_Bank1->BTCR[1] |= 16 << 8;
FMC_Bank1E->BWTR[0] |= 0 << 28;
FMC_Bank1E->BWTR[0] |= 4 << 0;
FMC_Bank1E->BWTR[0] |= 16 << 8;
FMC_Bank1->BTCR[0] |= 1 << 0;
// FMC_Bank1->BTCR[0] |= (u32)1 << 31; //使能FMC
delay_us(10);
FMC_Bank1->BTCR[2] = 0X00000000;
FMC_Bank1->BTCR[3] = 0X00000000;
FMC_Bank1E->BWTR[2] = 0X00000000;
// FMC_Bank1->BTCR[3] = FMC_Bank1->BTCR[1];
// FMC_Bank1E->BWTR[2] = FMC_Bank1E->BWTR[0];
FMC_Bank1->BTCR[2] |= 1 << 12;
FMC_Bank1->BTCR[2] |= 1 << 14;
FMC_Bank1->BTCR[2] |= 1 << 4;
FMC_Bank1->BTCR[3] |= 0 << 28;
FMC_Bank1->BTCR[3] |= 4 << 0;
FMC_Bank1->BTCR[3] |= 16 << 8;
FMC_Bank1E->BWTR[2] |= 0 << 28;
FMC_Bank1E->BWTR[2] |= 4 << 0;
FMC_Bank1E->BWTR[2] |= 16 << 8;
FMC_Bank1->BTCR[2] |= 1 << 0;
FMC_Bank1->BTCR[0] |= (u32)1 << 31;
delay_ms(50);
}
//port test
#define Port_Testdata1 (( vu16) ((BASE_ADDRNE1+(0xfa<<17)))) // USB MARK DATA
#define Port_Testdata2 (( vu16) ((BASE_ADDRNE1+(0xfb<<17)))) // USB MARK DATA
#define Port_Testdata3 (( vu16) ((BASE_ADDRNE1+(0xfc<<17)))) // USB MARK DATA
#define Port_Testdata4 (( vu16) ((BASE_ADDRNE1+(0xfd<<17)))) // USB MARK DATA
#define Port_Testdata5 (( vu16) ((BASE_ADDRNE1+(0xfe<<17)))) // USB MARK DATA
#define Port_Testdata6 (( vu16) ((BASE_ADDRNE1+(0xff<<17)))) // USB MARK DATA
#define Port_Testdata21 (( vu16) ((BASE_ADDRNE2+(0xfa<<17)))) // USB MARK DATA
#define Port_Testdata22 (( vu16) ((BASE_ADDRNE2+(0xfb<<17)))) // USB MARK DATA
#define Port_Testdata23 (( vu16) ((BASE_ADDRNE2+(0xfc<<17)))) // USB MARK DATA
#define Port_Testdata24 (( vu16) ((BASE_ADDRNE2+(0xfd<<17)))) // USB MARK DATA
#define Port_Testdata25 (( vu16) ((BASE_ADDRNE2+(0xfe<<17)))) // USB MARK DATA
#define Port_Testdata26 (( vu16) ((BASE_ADDRNE2+(0xff<<17)))) // USB MARK DATA
u16 temptt[10];
#define BASE_ADDRNE1 0x60000000
#define BASE_ADDRNE2 0x64000000
#define BASE_ADDRNE3 0x68000000
#define BASE_ADDRNE4 0x6C000000
while(1)
{
// Port_Testdata4=ii;
// ii++;
// Port_Testdata5=ii;
// ii++;
// Port_Testdata6=ii;
// ii++;
Port_Testdata24=ii;
ii++;
// Port_Testdata25=ii;
// ii++;
// Port_Testdata26=0xffff;
// ii++;
delay_us(1);
// temptt[0]=Port_Testdata1;
//
// temptt[1]=Port_Testdata2;
//
// temptt[2]=Port_Testdata3;
//
// temptt[3]=Port_Testdata4;
//
// temptt[4]=Port_Testdata5;
//
// temptt[5]=Port_Testdata6;
//
// temptt[6]=Port_Testdata23;
// temptt[7]=Port_Testdata24;
// temptt[8]=Port_Testdata25;
// temptt[9]=Port_Testdata26;
}
图片如下,可以看到NE2明显不对。黄色线位NWE信号,蓝色线位NE信号