我目前正在设置STM32F407以评估使用瑞萨R61526A显示控制器的显示模块。我能够使用CubeMX设置项目没有问题,FSMC似乎正在工作。
但是我注意到输出数据字是大端,但我很确定所有STM32都是小端(当使用示波器监视D0-16输出时,uint16_t 0x51ab作为变量变为0xab51)。我没想到FSMC会改变输出的字节顺序。- #define LCDADDRESS 0x63FFF00F
- const LCDmemorymapping LCDRWregisteraccess = (uint16_t*) LCDADDRESS;
- static void writetoLCD(uint16_t dataword)
- {
- *LCDRWregisteraccess= (uint16_t) dataword;
- }
- static uint16_t readfromLCD(uint16_t unused)
- {
- return (uint16_t) *LCDRWregisteraccess;
- }
- /* FSMC initialization function */
- static void MX_FSMC_Init(void)
- {
- FSMC_NORSRAM_TimingTypeDef Timing;
- /** Perform the SRAM1 memory initialization sequence
- */
- hsram1.Instance = FSMC_NORSRAM_DEVICE;
- hsram1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
- /* hsram1.Init */
- hsram1.Init.NSBank = FSMC_NORSRAM_BANK1;
- hsram1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE;
- hsram1.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM;
- hsram1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
- hsram1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
- hsram1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
- hsram1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
- hsram1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
- hsram1.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;
- hsram1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
- hsram1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE;
- hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
- hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
- hsram1.Init.PageSize = FSMC_PAGE_SIZE_NONE;
- /* Timing */
- Timing.AddressSetupTime = 3;
- Timing.AddressHoldTime = 15;
- Timing.DataSetupTime = 8;
- Timing.BusTurnAroundDuration = 3;
- Timing.CLKDivision = 16;
- Timing.DataLatency = 17;
- Timing.AccessMode = FSMC_ACCESS_MODE_A;
- /* ExtTiming */
- if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK)
- {
- _Error_Handler(__FILE__, __LINE__);
- }
- }
复制代码我希望输出也是小端的,所以我做了一些明显错误的事情吗?显而易见的解决方案是将数据读/写为*LCDRWregisteraccess= (uint16_t)((0xff00&dataword)>>8)|(0x00ff&dataword<<8));或者只是使用REV16指令,但我想知道FSMC中是否存在我缺少的配置或者我做错了什么。这也是我的第一个堆栈交换问题,所以如果我没有正确地提出问题,请随意指出提前谢谢了!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我的地址现在是:
#define LCD_CMD 0x60030000
#define LCD_DATA 0x60000000
一周热门 更多>