Back in early 2010 I asked our Freescale support people the following question:
> Date: Fri, 15 Jan 2010 10:28:11 +1100>> Are there any documents giving the real timing of the four> interrupts, the video and the loading of LCD_SSAR? I've spend> days on reverse engineering and I don't know enough to guarantee> reliable programming (without flashes and frame overwrites) yet.
I now have an answer, which can be summarised as:
NO
There are no documents, and the timing is still unspecified and unknown.
Which makes it very easy to write graphics code that doesn't work accasionally, where the screen flickers and flashes when the software and hardware get out of sync. Very visible bugs.
While writing code to try and measure the timing, I ran across a nasty bug in the LCDC which means that you can't trust the contents of the LCDC LCD_ISR Interrupt Status Register to tell you what is going on inside the module. That is documented here:
https://community.freescale.com/message/88350#88350
But back to the SSAR reload timing. Here's what I asked Freescale through our representative a few months ago, which also explains the timing I was measiring (I've edited this slightly for the benefit of this forum):
Subject: Re: Freescale MCF5329 LCD Controller SSAR Load TimingDate: Mon, 23 May 2011 12:06:53 +1000 QUESTION ======== When does the SSAR reload take place relative to the EOF and BOF interrupts? Does it happen immediately after (or possibly even slightly before) the EOF, just prior to the BOF or mid-way? How many nanoseconds. How many clock edges (and which clocks)?Here's a diagram giving the timing I'm seeing, and deriving the "4.5us" figure I'll keep mentioning:Pixel Data (8MHz)__i__i__i__i__i__i__i__i__i__i_ // I_i__i__i__i_FIFO depth pix 26 25 24 31 38 45 51 58 57 56 // 25 24 23 31DMA Read R4 R4 R4 R4 R4 // R4 R4Interrupts? EOF ^ BOF ^LSSAR Reload __________?????????????????????????????????______Time |<-- 550ns -->|<--- 4.5 us ---->|The 16-bit pixel rate is 8MHz. The "screen" is 400 * 210. The video DMA is set for 20-word bursts. This means the BOF and EOF indications are 4.5us apart. "R4" above is a four-32-bit burst read of the SDRAM (at 11 80MHz clocks per burst, totaling 550ns). These happen in burst of 5, taking500ns each and spaced at 5us. The SSAR is (assumed to be) reloadedsomewhere between the EOF and BOF indications, with a 4.5us uncertainty.
The answer I got back from Freescale was:
Subject: RE: Freescale MCF5329 LCD Controller LCD_ISR Missing Signals on ReadingDate: Fri, 10 Jun 2011 08:04:33 +08001) For the SSAR reload question, the SSAR is reloaded at the exact time that the EOF interrupt occurs. This is why the recommendationin the reference manual is to load it at BOF, to ensure it won'tbe misloaded. Hopefully this information can enable you to achievethe LCD refresh that you are trying to create.
I then wrote some code to test the above, and found that the SSAR Reload happens somewhere between the time where the EOF is generated, and 1500us BEFORE that!
After reporting that back I now have a more definite answer:
Subject: RE: Freescale MCF5329 LCD Controller LCD_ISR Missing Signals on ReadingDate: Fri, 8 Jul 2011 07:04:26 +0800To close out the discussion, I was able to get some more clarificationfrom the design team. The new SSAR value takes effect when the once the current frame is finished. This is what triggers an EOF interrupt,but hence why the load could occur slightly before that. I apologizefor misunderstanding earlier when I wrote that it would occur exactly atthe same time as the EOF interrupt, it was specifically to the end of frame internal to the LCD controller instead.
Summarising:
The new SSAR value takes effect when the ... current frame is finished (measured at) the end of frame internal to the LCD controller.
Those "internal" events aren't visible externally.
But it seems to be like the following in our case, with different clocks and memory timing it'll be different):
Pixel Data (8MHz)__i__i__i__i__i__i__i__i__i__i_ // I_i__i__i__i_FIFO depth pix 26 25 24 31 38 45 51 58 57 56 // 25 24 23 31DMA Read R4 R4 R4 R4 R4 // R4 R4Interrupts? EOF ^ BOF ^Time |<-- 550ns -->|<--- 4.5 us ---->|LSSAR Load _?????_Somewhere_in_here_?????______________________Time |<----- 1500ns ------------>|
To handle the measured 1500ns of uncertainty, my graphics code reloads the SSAR and then waits (in a hard loop with interrupts disabled) for 3us (double 1500ns) to see if the EOF interrupt happens in that time. It can't read the LCD_ISR as that doesn't work, so it has to monitor the interrupt controller registers. If the interrupt has happened then the reload may or may not have worked, and this has to be signaled to the EOF interrupt code so it knows to skip to the next interrupt before allowing more writes.
Tom