本帖最后由 liuwanwei 于 2017-9-16 16:49 编辑
我使用F7来驱动TFT没反应,发现如果连续调用写数据函数,NWE和NE只出现一次跳变,但数据位上又有相应写数据个数的跳变,就证明MCU确实是输出了这么多次数据的,难道速度太快了吗?配置是基于原子的F7例程来的,不应该呀。
如果在每个写数据函数之间加个1微秒廷时,则波形是对的。
有哪们兄弟遇到过这个问题?
图片2是有问题的波形,图片1是加了1us廷时后的波形。
下面是测试写的程序段
while(1)
{
LCD_WR_REG(0x00<<14);
delay_us(1);
LCD_WR_REG(0x01<<14);
delay_us(1);
LCD_WR_REG(0x02<<14);
delay_us(1);
LCD_WR_REG(0x03<<14);
delay_us(10);
}
下面是FMC和MPU的配置:
LCD_MPU_Config(); //ʹÄÜMPU±£»¤LCDÇøÓò
SRAM_Handler.Instance=FMC_NORSRAM_DEVICE;
SRAM_Handler.Extended=FMC_NORSRAM_EXTENDED_DEVICE;
SRAM_Handler.Init.NSBank=FMC_NORSRAM_BANK4; //ʹÓÃNE4
SRAM_Handler.Init.DataAddressMux=FMC_DATA_ADDRESS_MUX_DISABLE; //²»¸´ÓÃÊý¾ÝÏß
SRAM_Handler.Init.MemoryType=FMC_MEMORY_TYPE_SRAM; //SRAM
SRAM_Handler.Init.MemoryDataWidth=FMC_NORSRAM_MEM_BUS_WIDTH_16; //16λÊý¾Ý¿í¶È
SRAM_Handler.Init.BurstAccessMode=FMC_BURST_ACCESS_MODE_DISABLE; //ÊÇ·ñʹÄÜÍ»·¢·ÃÎÊ,½ö¶Ôͬ²½Í»·¢´æ´¢Æ÷ÓÐЧ,´Ë´¦Î´Óõ½
SRAM_Handler.Init.WaitSignalPolarity=FMC_WAIT_SIGNAL_POLARITY_LOW;//µÈ´ýÐźŵļ«ÐÔ,½öÔÚÍ»·¢Ä£Ê½·ÃÎÊÏÂÓÐÓÃ
SRAM_Handler.Init.WaitSignalActive=FMC_WAIT_TIMING_BEFORE_WS; //´æ´¢Æ÷ÊÇÔڵȴýÖÜÆÚ֮ǰµÄÒ»¸öʱÖÓÖÜÆÚ»¹ÊǵȴýÖÜÆÚÆÚ¼äʹÄÜNWAIT
SRAM_Handler.Init.WriteOperation=FMC_WRITE_OPERATION_ENABLE; //´æ´¢Æ÷дʹÄÜ
SRAM_Handler.Init.WaitSignal=FMC_WAIT_SIGNAL_DISABLE; //µÈ´ýʹÄÜλ,´Ë´¦Î´Óõ½
SRAM_Handler.Init.ExtendedMode=FMC_EXTENDED_MODE_ENABLE; //¶ÁдʹÓò»Í¬µÄʱÐò
SRAM_Handler.Init.AsynchronousWait=FMC_ASYNCHRONOUS_WAIT_DISABLE;//ÊÇ·ñʹÄÜͬ²½´«ÊäģʽϵĵȴýÐźÅ,´Ë´¦Î´Óõ½
SRAM_Handler.Init.WriteBurst=FMC_WRITE_BURST_DISABLE; //½ûֹͻ·¢Ð´
SRAM_Handler.Init.ContinuousClock=FMC_CONTINUOUS_CLOCK_SYNC_ASYNC;
//FSMC¶ÁʱÐò¿ØÖƼĴæÆ÷
FSMC_ReadWriteTim.AddressSetupTime=0x11; //µØÖ·½¨Á¢Ê±¼ä(ADDSET)Ϊ17¸öHCLK 1/216M=4.6ns*17=78ns
FSMC_ReadWriteTim.AddressHoldTime=0x00;
FSMC_ReadWriteTim.DataSetupTime=0x55; //Êý¾Ý±£´æʱ¼ä(DATAST)Ϊ85¸öHCLK =4.6*85=391ns
FSMC_ReadWriteTim.AccessMode=FMC_ACCESS_MODE_A; //ģʽA
//FSMCдʱÐò¿ØÖƼĴæÆ÷
FSMC_WriteTim.AddressSetupTime=0x15; //µØÖ·½¨Á¢Ê±¼ä(ADDSET)Ϊ21¸öHCLK=96ns
FSMC_WriteTim.AddressHoldTime=0x00;
FSMC_WriteTim.DataSetupTime=0x15; //Êý¾Ý±£´æʱ¼ä(DATAST)Ϊ4.6ns*21¸öHCLK=96ns
FSMC_WriteTim.AccessMode=FMC_ACCESS_MODE_A; //ģʽA
HAL_SRAM_Init(&SRAM_Handler,&FSMC_ReadWriteTim,&FSMC_WriteTim);
//ÅäÖÃMPUµÄregion(SRAMÇøÓòΪ͸дģʽ)
void LCD_MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_Initure;
HAL_MPU_Disable(); //ÅäÖÃMPU֮ǰÏȹرÕMPU,ÅäÖÃÍê³ÉÒÔºóÔÚʹÄÜMPU
//ÍⲿSRAMΪregion0£¬´óСΪ2MB£¬´ËÇøÓò¿É¶Áд
MPU_Initure.Enable=MPU_REGION_ENABLE; //ʹÄÜregion
MPU_Initure.Number=LCD_REGION_NUMBER; //ÉèÖÃregion£¬ÍⲿSRAMʹÓõÄregion0
MPU_Initure.BaseAddress=LCD_ADDRESS_START; //region»ùµØÖ·
MPU_Initure.Size=LCD_REGION_SIZE; //region´óС
MPU_Initure.SubRegionDisable=0X00;
MPU_Initure.TypeExtField=MPU_TEX_LEVEL0;
MPU_Initure.AccessPermission=MPU_REGION_FULL_ACCESS; //´Ëregion¿É¶Áд
MPU_Initure.DisableExec=MPU_INSTRUCTION_ACCESS_ENABLE; //ÔÊÐí¶ÁÈ¡´ËÇøÓòÖеÄÖ¸Áî
MPU_Initure.IsShareable=MPU_ACCESS_NOT_SHAREABLE;
MPU_Initure.IsCacheable=MPU_ACCESS_NOT_CACHEABLE;
MPU_Initure.IsBufferable=MPU_ACCESS_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_Initure);
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); //¿ªÆôMPU
}
|