Add graphics without employing dedicated graphics controller
Keywords:graphics controller? LCD? microcontroller?
The low-cost, controllerless (LCC) software driver from the microcontroller supplier should help with synchronizing timing parameters, such as pulse-width, front-porch, and back-porch, for both horizontal and vertical pulses. These timing constants can be found in the data sheet of the specific LCD Panel to be used. It is usually a value given in pixel clocks. These constants help set up the proper frequencies needed to produce an accurate image data on the display.
The following code snippet from an LCC driver library illustrates the steps to set up a system that operates a controllerless graphics configuration.
//Suspend ALL DMA transfers
DMACONbits.SUSPEND =1;
#define PMP_CONTROL
(PMP_ON|PMP_MUX_OFF|PMP_READ_WRITE_EN|\PMP_CS2_EN|PMP_CS2_POL_LO|PMP
_WRITE_POL_LO|PCLK_POLARITY)
#define PMP_MODE
(PMP_DATA_LENGTH|PMP_MODE_MASTER2|\PMP_WAIT_BEG_1|PMP
_WAIT_MID_1|PMP_WAIT_END_1)
// Set up the PMP
// PMP is setup to use data and address lines, in 16 bit PMP mode
// PMP wait states are set to fastest
mPMPOpen(PMP_CONTROL, PMP_MODE, PMP_ADDRESS_LINES, PMP_INT_ON);
//Set PMP address to 0
PMADDR = 0x0000;
// Open the desired DMA channel
DmaChnOpen(1, 0, DMA_OPEN_DEFAULT);
// Set the transfer event control: what event is to start the DMA transfer
DmaChnSetEventControl(1, DMA_EV_START_IRQ(_TIMER_2_IRQ));
// Set the transfer parameters: source & destination address, source & destination size,number of bytes per event source is the PMP, destination is a dummy array, source size is 2 for 16bit color, first destination size is the backporch, transfers per event is two.
DmaChnSetTxfer(1, (void*)&PMDIN ,&GraphicsFrame[0] , 2, HBackPorch, 2);
// Set INT controller priority to 7 for highest priority
INTSetVectorPriority(INT_VECTOR_DMA(1), INT_PRIORITY_LEVEL_7);
// Set INT controller sub-priority
INTSetVectorSubPriority(INT_VECTOR_DMA(1),
INT_SUB_PRIORITY_LEVEL_3);
// Enable the transfer done interrupt, when all buffer transferred
DmaChnSetEvEnableFlags(1, DMA_EV_BLOCK_DONE);
// Enable the interrupt in the INT controller
INTEnable(INT_SOURCE_DMA(1), INT_ENABLED);
// Once configured, enable the DMA channel
DmaChnEnable(1);
// Turn on Timer2 to act as a "trigger" for the pixel clock (DMA transfer)
OpenTimer2(T2_ON | T2_SOURCE_INT | T2_PS_1_1, 10);
// Start ALL DMA transfers
DMACONbits.SUSPEND = 0;
Other considerations
Just because you can use a controllerless configuration to manage the graphics display does not mean it will always be the best idea. For example, a graphics controller may make more sense if your graphical interface needs the performance benefits of hardware acceleration, such as to implement alpha blending, transparency, or scrolling functions. Using larger display resolutions can push the processing requirements beyond the range that a controllerless implementation can support. Also, a deep color depth, such as using a 24bit color depth, can exceed the performance that the controllerless method can deliver.
These considerations aside, using a controllerless approach usually provides cost benefits, but there are some tradeoffs for those benefits. For example, there is some CPU overhead for managing the continuous LCD refresh. The Interrupt Service Routine (ISR) that updates the LCD timing constraints is the only part of the system that consumes CPU bandwidth because everything else is handled by the DMA transfer.
Related Articles | Editor's Choice |
Visit Asia Webinars to learn about the latest in technology and get practical design tips.