cancel
Showing results for 
Search instead for 
Did you mean: 

How to disable TouchGFX reading from external Flash while writting to external flash. Model::tick() stops being executed.

manto.1
Senior

Model::tick() I am using external Flash (16 MB) for storing pictures, texts and fonts for TouchGFX. External flash is also used for storing some parameters using simulated EEprom.

External flash is normaly used in memory mapped mode. Only when storing parameters is memory mapped mode disabled.

If writing to external flash is frequent Model::tick() stops being executed.

This is the task handling writing to in external flash. It gets paramters from a queue.

void UserEEpromTask(void *params)
{
	BaseType_t baseType = pdFALSE;
	EE_Status ee_status;
	while(1)
	{
		uint8_t EEpromQueueFillLevel = uxQueueMessagesWaiting(Queue_EEpromHandle);
		if(EEpromQueueFillLevel > 0){
			baseType = xQueueReceive(Queue_EEpromHandle, &eepromQueueMsg, 1);
			if ((baseType == pdPASS) && (eepromQueueMsg.id > 0))
			{
			    NVIC_DisableIRQ(DMA2D_IRQn);
			    NVIC_DisableIRQ(LTDC_IRQn);
			    taskENTER_CRITICAL();
				ExternalFlash_StatusTypeDef stat;
				stat = ExtFlash_Abort(&hqspi);
				if(stat == EXT_FLASH_OK){
					if((ee_status = EE_WriteVariable32bits(eepromQueueMsg.id, eepromQueueMsg.data)) != EE_OK){
						if (ee_status == EE_CLEANUP_REQUIRED){
							 if(EE_CleanUp() != EE_OK)
								 ;//Error_Handler();
						}
					}
				}
				stat = ExtFlash_MemoryMap (&hqspi);
				taskEXIT_CRITICAL();
			    NVIC_EnableIRQ(DMA2D_IRQn);
			    NVIC_EnableIRQ(LTDC_IRQn);
			}
		}
		osDelay(100);
	}
}

5 REPLIES 5
RetroInTheShade
Associate III

Hi Manto,

Have a look at this thread for some pointers of what we tried!

https://community.st.com/s/question/0D53W00001OMADmSAP/external-flash-assets-updates-while-touchgfx-is-running

Thank you for the answer!

How do I know or how to check that endFrame() was called (to confirm frame  generation complete).

Also, do I need to implement a bug fix shown here or is this already solved in TouchGFX_4.16.1?

https://support.touchgfx.com/4.15/docs/miscellaneous/known-issues#textarea-and-chromart-dma2d

RetroInTheShade
Associate III

Hi Manto,

The endFrame() function in TouchGFXHAL.cpp will be called by the framework. Once parent function called to perform necessary actions, you can insert your code to synchronize your eerpom task.

void TouchGFXHAL::endFrame()
{
    HAL::endFrame();
    if (frameBufferUpdatedThisFrame)
    {
        refreshRequested = true;
    }
 
     /* Step 1:  Disabled TouchGFX interrupts*/ 
    disableInterrupts();
    
    /* Step 2:  Release mutex or msg your eeprom thread*/
   
    /* Step 3:  Wait on mutex or flag to indicate eeprom thread done*/   
 
   /* Step 4:   Enable memory mapped mode again */
    
    /*Step 5:  Enable TouchGFX interrupts */
    enableInterrupts();
 
}

I suspect bug is fixed but cannot confirm.

manto.1
Senior

So i should write to external flash inside of endFrame method between step 3 and 4 ?

RetroInTheShade
Associate III

Yes, you could.  

Once you have it working you might  move to mutex or flag to separate the eeprom functionality from touchgfx.