• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

Setting pixel location on CFAF240320K-T-TS


New member
It was fairly easy to get the CFAF240320K-T-TS working to draw a full screen test pattern, etc., but I can't see how to set a single individual pixel at a location other than 0,0. For example, the following code should (in my mind) set the pixel location to 10, 10 and draw one green pixel, but any drawing always starts at 0,0.

lcdDrawPixel(10, 10, GREEN);

void lcdSetCursor(uint16_t x, uint16_t y)
  lcdWriteCmd(0x0020); // GRAM Address Set (Horizontal Address) (R20h)
  lcdWriteCmd(0x0021); // GRAM Address Set (Vertical Address) (R21h)

void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color)
  lcdSetCursor(x, y);
  lcdWriteCmd(0x0022);  // Write Data to GRAM (R22h)
Perhaps I'm doing something fundamentally wrong, but looking at the datasheet I had the impression you could set the starting location with 0x20 and 0x21, but perhaps not? Is there a straight-forward way to only draw single pixels and random locations (to draw fonts, etc.)? I'm sure there is ... I'm just hoping someone can point me in the right direction. ;)
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.


New member
The problem was the entry mode register. ORG (bit 7) was set to 1 which will cause the device to ignore any address and always start at 0. Setting it to 0 (in the init code) fixed the problem, as follows:

  lcdWriteCmd(0x0003);    // Entry Mode (R03h)
  // Page 15, SPFD5408B Datasheet 
  lcdWriteData(0x0000 | 1<<14			// DFM
                      | 1<<12			// BGR
                      | 0<<7			// ORG
                      | 0<<5			// ID/1
                      | 0<<4			// ID/0
                      | 0<<3			// AM
Last edited: