chipKIT® Development Platform

Inspired by Arduino™

Tearing effect in Picadillo

Created Sat, 23 Jul 2016 15:54:14 +0000 by apmega


Sat, 23 Jul 2016 15:54:14 +0000


I'm trying to display rapidly changing images (basically a movie) on the picadillo. However, I get a strong tearing effect (TE; visible flicker) when frame rate is below 50ms.

I looked at the specs, and the HX8357 can return the TE signal. TE is activated during initialization of the device (in picadillo.cpp) but I can not see any further evidence for actually using it (unless it is done automatically bu the controller, which is unlikely due to the strong flicker). Just for sanity check, I hooked my picadillo to a different computer, installed all the libraries and ran the example primitives.ino, and sure thing, reducing the delay between frames introduces flicker.

I'm sure there is a simple solution to this? Basically any code that allows movies should have solved this by now...

I would appreciate your comments on this




Sat, 23 Jul 2016 21:27:47 +0000

I believe the tear signal is presented on the FMARK pin of the TFT screen. That pin isn't connected to anything by the looks of things. So the frame sync signal is not available for use.

The connector for the TFT is so tiny that it's almost impossible to solder a wire to that pin - certainly without a microscope and some very expensive soldering equipment. And an incredibly steady hand.

There is a function "GETSCAN" in the HX8357 command set which returns the current scan line that is being rendered. It may be possible to use that to synchronise the display to some extent. Sitting in a tight loop probing that value and waiting for it to wrap round from a high value to a low value would indicate that the scan had started from the top of the screen again. I guess looking for a specific value may be unreliable, hence looking to see if it has hit the bottom of the screen and started from the top again.

... except that I can't get it to read anything from that register at the moment. So I'll keep trying and keep you informed of my findings.


Sat, 23 Jul 2016 21:44:39 +0000


I really appreciate this. I also tried to read the scanline, but got nothing.

Another possible direction I was contemplating was to sync the write and refresh cycles. I tried to check for end of the busy signal on the DMA. I introduced this line to the code: while (DCH3CONbits.CHBUSY); before each PMDIN update.

for example, my modified fillRectangle function looks something like this:

void fillRectangle(int x, int y, int w, int h, byte data) { tft.setAddrWindow(x, dy, x+w-1, dy+h-1);
PMADDR = 0x0001; for(y=h; y>0; y--) { for(x=w; x>0; x--) { while (DCH3CONbits.CHBUSY); //probably just a delay PMDIN = data; } } }

This significantly improves the flicker, but most likely not for the reason I anticipated. For example, If I check for the busy signal twice, the flicker reappears. It is likely that this command helps to synchronize the write / update rates. But is it an accident? I don't know.

Perhaps, if this a hardware issue I should address it to the 4dsystem guys



Sat, 23 Jul 2016 21:49:29 +0000

If you want it done properly then you need that TE (FMARK?) signal (they can confirm it is that signal) and that can only be done by them in the next iteration of the Picadillo.


Tue, 26 Jul 2016 17:46:04 +0000

I just heard back from 4D. The FMARK signal is available, it's just not wired in.

Just below the 4D logo, below 2 resistors, is a hole in a box with FMARK just discernible above it. Solder a wire from that hole and connect it to the GPIO pin of your choice. It might be good to connect it to one of the interrupt pins so that an interrupt can be generated every time the TE pulses.

I haven't tried it out yet (just got back from a short holiday) but it should do the trick nicely.


Tue, 26 Jul 2016 21:07:33 +0000

Perfect! It works now!

My solution is not very sophisticated, I'm not using interrupts. I have connected the FMARK line to RE8, and then read the status of the E port (this is too slow to read before every write command, so I read it every line, it seems to be OK for all line lengths I have tested). Also, I would that it helps to setthe tearing effect mode on the LCD to 1. Here is the new code:


tft.writeCommand(0x35);//activate Tearing Effect tft.writeData(1);//read horizontal and vertical TE signals

tft.setAddrWindow(x, y, x+w-1, y+h-1); PMADDR = 0x0001; for(int dy=0; dy<h; dy++) {

  do{//check if LCD is scanning
  }while((PORTE&amp;0b100000000)==0); //R#8 on Port E

  for(int dx=0; dx&lt;w; dx++) {  
       PMDIN=color; //write the actual color data


//... Thanks a lot for your help!