Hello Luis.
I downloaded the SC code, I changed to a new version and I've been trying to make the LCDC module to work and it is still the same, no Vsync or Hsync signals out of the ports...
This is my new code, it is practically the same provided by the SC and it is not working. What can I do? Who can help me with this?
/*
* main implementation: use this 'C' sample to create your own application
*
*/
#include "derivative.h" /* include peripheral declarations */
//#include "common.h"
//#include "lcdc.h"
//#include "lptmr.h"
//#include "sdram.h"
#define SCREEN_XSIZE 480
#define SCREEN_YSIZE 272
#define GW_XSIZE (SCREEN_XSIZE/2)
#define GW_YSIZE (SCREEN_YSIZE/2)
#define FRAME_START_ADDRESS 0x80400000 //Screen in DDR
#define GW_START_ADDRESS 0x80200000
#define FRAME_BUFFER_SIZE (SCREEN_XSIZE * SCREEN_YSIZE * 4) //4 bytes per pixel for 24bpp
#define GW_BUFFER_SIZE (GW_XSIZE * GW_YSIZE * 4) //4 bytes per pixel for 24bpp
int main(void)
{
int counter = 0;
// printf("LCD Controller Example\n");
//Enable Port clocks
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK;
/* Enable LCDC and DDR Modules */
SIM_SCGC3 |= SIM_SCGC3_LCDC_MASK;
/* Disable MPU */
MPU_CESR &= ~MPU_CESR_VLD_MASK;
/* LCDC configuration for TWR-LCD-RGB */
lcdc_init_screen();
lcdc_color_demo();
for(;;) {
counter++;
}
return 0;
}
void lcdc_color_demo()
{
color_demo_data(); //Create the frame buffer data for background plane and graphic window
color_demo_gw_setup(); //Initialize the graphic window registers for this demo
// set LCD Screen Start Address
LCDC_LSSAR = FRAME_START_ADDRESS;
// set LCD graphic window start address
LCDC_LGWSAR = GW_START_ADDRESS;
SIM_MCR|=SIM_MCR_LCDSTART_MASK; //Start LCDC
// printf("Hit any key to turn on/off the graphic window\n");
while(1)
{
// in_char(); //Wait for input
// LCDC_LGWCR&=~LCDC_LGWCR_GWE_MASK; //Turn off graphic window
// in_char(); //Wait for input
LCDC_LGWCR|=LCDC_LGWCR_GWE_MASK; //Turn on graphic window
}
}
void color_demo_data(void)
{
int *pointer32;
int i,n;
/*
* Create the frame buffer so that the screen will be divided into 4 quadrants
* of a different color:
* RG
* BW
*/
pointer32=(int *)FRAME_START_ADDRESS;
//Loop through top half of screen
for(i=0;i<SCREEN_YSIZE/2;i++)
{
//One half will be red
for(n=0;n<SCREEN_XSIZE/2;n++)
{
*pointer32=0x00FF0000; //Red
pointer32++;
}
//One half will be green
for(n=0;n<SCREEN_XSIZE/2;n++)
{
*pointer32=0x0000FF00; //Green
pointer32++;
}
}
//Loop through bottom half of screen
for(i=0;i<SCREEN_YSIZE/2;i++)
{
//One half will be blue
for(n=0;n<SCREEN_XSIZE/2;n++)
{
*pointer32=0x000000FF; //Blue
pointer32++;
}
//One half will be white
for(n=0;n<SCREEN_XSIZE/2;n++)
{
*pointer32=0x00FFFFFF; //White
pointer32++;
}
}
/* Create a graphic window filled with the color black*/
pointer32=(int *)GW_START_ADDRESS;
for(i=0;i<GW_BUFFER_SIZE/4;i++)
{
*pointer32=0x00000000; //Black
pointer32++;
}
}
void color_demo_gw_setup(void)
{
// set LCD graphic window size
LCDC_LGWSR =
LCDC_LGWSR_GWW(GW_XSIZE/16) |
LCDC_LGWSR_GWH(GW_YSIZE);
// set LCD graphic window virtual page width
LCDC_LGWVPWR = GW_XSIZE;
// set LCD graphic window panning offset (not used in 24bpp mode)
LCDC_LGWPOR = 0;
// set LCD graphic window position so that the GW will cover up the middle of screen
LCDC_LGWPR =
LCDC_LGWPR_GWXP(SCREEN_XSIZE/4) |
LCDC_LGWPR_GWYP(SCREEN_YSIZE/4);
// set LCD graphic window control
LCDC_LGWCR =
LCDC_LGWCR_GWAV(0xff) | // alpha-transparent value (0xFF is opaque)
LCDC_LGWCR_GWE_MASK;
}
void lcdc_init_pins()
{
#define ALT2 (0|PORT_PCR_MUX(2)|PORT_PCR_DSE_MASK)
#define ALT5 (0|PORT_PCR_MUX(5)|PORT_PCR_DSE_MASK)
#define ALT7 (0|PORT_PCR_MUX(7)|PORT_PCR_DSE_MASK)
PORTF_PCR4 =ALT7; // Graphic LCD D[0], Schematic PTF4
PORTF_PCR5 =ALT7; // Graphic LCD D[1], Schematic PTF5
PORTF_PCR6 =ALT7; // Graphic LCD D[2], Schematic PTF6
PORTF_PCR7 =ALT7; // Graphic LCD D[3], Schematic PTF7
PORTF_PCR8 =ALT7; // Graphic LCD D[4], Schematic PTF8
PORTF_PCR9 =ALT7; // Graphic LCD D[5], Schematic PTF9
PORTF_PCR10=ALT7; // Graphic LCD D[6], Schematic PTF10
PORTF_PCR11=ALT7; // Graphic LCD D[7], Schematic PTF11
PORTF_PCR12=ALT7; // Graphic LCD D[8], Schematic PTF12
PORTF_PCR13=ALT7; // Graphic LCD D[9], Schematic PTF13
PORTF_PCR14=ALT7; // Graphic LCD D[10], Schematic PTF14
PORTF_PCR15=ALT7; // Graphic LCD D[11], Schematic PTF15
PORTF_PCR16=ALT5; // Graphic LCD D[12], Schematic PTF16
PORTF_PCR17=ALT5; // Graphic LCD D[13], Schematic PTF17
PORTF_PCR18=ALT5; // Graphic LCD D[14], Schematic PTF18
PORTF_PCR19=ALT5; // Graphic LCD D[15], Schematic PTF19
PORTF_PCR20=ALT5; // Graphic LCD D[16], Schematic PTF20
PORTF_PCR21=ALT7; // Graphic LCD D[17], Schematic PTF21
PORTF_PCR22=ALT7; // Graphic LCD D[18], Schematic PTF22
PORTF_PCR23=ALT7; // Graphic LCD D[19], Schematic PTF23
PORTF_PCR24=ALT7; // Graphic LCD D[20], Schematic PTF24
PORTF_PCR25=ALT7; // Graphic LCD D[21], Schematic PTF25
PORTF_PCR26=ALT7; // Graphic LCD D[22], Schematic PTF26
PORTF_PCR27=ALT7; // Graphic LCD D[23], Schematic PTF27
PORTF_PCR0=ALT7; // Graphic LCD PCLK, Schematic PTF0
PORTF_PCR1=ALT7; // Graphic LCD DE, Schematic PTF1
PORTF_PCR2=ALT7; // Graphic LCD HSYNC, Schematic PTF2
PORTF_PCR3=ALT7; // Graphic LCD VSYNC, Schematic PTF3
// set LCD_CONTRAST
//PORTB_PCR4=ALT2; // Graphic LCD CONTRAST, Schematic PTB4
}
void lcdc_init_screen()
{
// set LCD Screen Start Address
LCDC_LSSAR = FRAME_START_ADDRESS;
// set LCD Size. The XMAX bitfield is the screen x-size/16.
LCDC_LSR = LCDC_LSR_XMAX( (SCREEN_XSIZE / 16) ) | LCDC_LSR_YMAX( SCREEN_YSIZE );
// set LCD virtual page width
LCDC_LVPWR = LCDC_LVPWR_VPW( SCREEN_XSIZE );
// set LCD cursor positon & settings (turn off)
LCDC_LCPR = 0;
LCDC_LCWHB = 0;
// set LCD panel configuration. Use endianess to work with TWR-LCD-RGB lines.
LCDC_LPCR =
LCDC_LPCR_TFT_MASK | //TFT Screen
LCDC_LPCR_COLOR_MASK | //Color
LCDC_LPCR_BPIX(0x2) | //4 bpp
LCDC_LPCR_FLMPOL_MASK | //first line marker active low (VSYNC)
LCDC_LPCR_LPPOL_MASK | //line pulse active low (HSYNC)
LCDC_LPCR_END_SEL_MASK | //Use big-endian mode (0xFFAA5500 means R=AA,G=55,B=00).
//LCDC_LPCR_SWAP_SEL_MASK | //Set if needed for LCD data lines match up correctly with the LCD
LCDC_LPCR_SCLKIDLE_MASK | //Enalbe LSCLK when vsync is idle
LCDC_LPCR_SCLKSEL_MASK | //Always enable clock
LCDC_LPCR_PCD(11); //Divide 120 PLL0 clock (default clock) by (11+1)=12 to get 10MHz clock
//If RevE or later TWR-LCD-RGB, need to adjust clock settings
#ifdef REVE
LCDC_LPCR |= LCDC_LPCR_CLKPOL_MASK; //In TFT mode, active on negative edge of LSCLK.
// set LCD horizontal configuration based on panel data (Figure 3-3 in Seiko datasheet)
LCDC_LHCR =
LCDC_LHCR_H_WIDTH(41) | //(41+1)=42 SCLK period for HSYNC activated
LCDC_LHCR_H_WAIT_1(1) | //(1+1)=2 SCLK period between end of OE and beginning of HSYNC
LCDC_LHCR_H_WAIT_2(0); //(0+3)=3 SCLK periods between end of HSYNC and beginning of OE
// set LCD vertical configuration based on panel data (Figure 3-3 in Seiko datasheet)
LCDC_LVCR =
LCDC_LVCR_V_WIDTH(2) | //2 lines period for VSYNC activated
LCDC_LVCR_V_WAIT_1(1) | //1 line period between end of OE and beginning of VSYNC
LCDC_LVCR_V_WAIT_2(1); //1 line periods between end of VSYNC and beginning of OE
//Earlier TWR-LCD-RGB versions (B, C, and D)
#else
LCDC_LHCR =
LCDC_LHCR_H_WIDTH(40) | //(40+1)=41 SCLK period for HSYNC activated
LCDC_LHCR_H_WAIT_1(1) | //(1+1)=2 SCLK period between end of OE and beginning of HSYNC
LCDC_LHCR_H_WAIT_2(0); //(0+3)=3 SCLK periods between end of HSYNC and beginning of OE
// set LCD vertical configuration based on panel data (Figure 3-3 in Seiko datasheet)
LCDC_LVCR =
LCDC_LVCR_V_WIDTH(10) | //10 lines period for VSYNC activated
LCDC_LVCR_V_WAIT_1(2) | //2 line period between end of OE and beginning of VSYNC
LCDC_LVCR_V_WAIT_2(2); //2 line periods between end of VSYNC and beginning of OE
#endif
// set the LCD panning offset (not used in 24bpp mode)
LCDC_LPOR = 0;
// set LCD interrupt configuration register
LCDC_LICR = 0;
//Disable LCDC interrupts
LCDC_LIER = 0;
//Disable the graphic window. See the "color" and "fsl" demos for examples of
// using the graphic window feature
LCDC_LGWCR &=~LCDC_LGWCR_GWE_MASK;
//Set background plane DMA to burst mode
LCDC_LDCR&=~LCDC_LDCR_BURST_MASK;
//Set graphic window DMA to burst mode
LCDC_LGWDCR&=~LCDC_LGWDCR_GWBT_MASK;
}