Display text on LCD Arrow Cyclone V Sockit

Hi, I am working with Arrow Cyclone V SocKit. I am using the linux 3.12
Linux version 3.12.0-00307-g507abb4-dirty (root@matthew) (gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-57) ) #1 SMP Fri Jun 27 09:59:35 CST 2014

I tried “hps_lcd” sample found on the CD and I managed to display the characters. When I tried combining hps_lcd and hps_gpio (for controlling LEDs and Switches) the LCD doesn’t show anything. The initialization is normal, LCD blinks but when I tried calling it from my loop, it doesn’t show anything.

Here’s part of my source code, note that flipFlop is an integer flag which is turned on and off by a thread.

Is there anything wrong with my code?

Thanks in advance.

source code:

LCD_CANVAS LcdCanvas;

LcdCanvas.Width 		= LCD_WIDTH;
LcdCanvas.Height 		= LCD_HEIGHT;
LcdCanvas.BitPerPixel 	= 1;
LcdCanvas.FrameSize 	= LcdCanvas.Width * LcdCanvas.Height / 8;
LcdCanvas.pFrame 		= (void *)malloc(LcdCanvas.FrameSize);

if (LcdCanvas.pFrame == NULL)
{
	printf("failed to allocate lcd frame buffer\r\n");
}
else
{			
	LCDHW_Init(virtual_base);
	LCDHW_BackLight(true); // turn on LCD backlight
	
	LCD_Init();

	// clear screen
	DRAW_Clear(&LcdCanvas, LCD_WHITE);

	// demo grphic api    
	DRAW_Rect(&LcdCanvas, 0,0, LcdCanvas.Width-1, LcdCanvas.Height-1, LCD_BLACK); // retangle
	DRAW_Circle(&LcdCanvas, 10, 10, 6, LCD_BLACK);
	DRAW_Circle(&LcdCanvas, LcdCanvas.Width-10, 10, 6, LCD_BLACK);
	DRAW_Circle(&LcdCanvas, LcdCanvas.Width-10, LcdCanvas.Height-10, 6, LCD_BLACK);
	DRAW_Circle(&LcdCanvas, 10, LcdCanvas.Height-10, 6, LCD_BLACK);

	// demo font
	DRAW_PrintString(&LcdCanvas, 40, 5, "SoCKit", LCD_BLACK, &font_16x16);
	DRAW_PrintString(&LcdCanvas, 40, 5+16, "Test", LCD_BLACK, &font_16x16);
	DRAW_PrintString(&LcdCanvas, 40, 5+32, "Mario", LCD_BLACK, &font_16x16);
	DRAW_Refresh(&LcdCanvas);       		
} 
	
// main loop
while(iRunning)
{
	// scan input from key or switch
	scan_input = alt_read_word( ( virtual_base + ( ( uint32_t )( ALT_GPIO2_EXT_PORTA_ADDR ) & ( uint32_t )( HW_REGS_MASK ) ) ) );			
	led_display = 0;
	
	/* MAIN LOOP */
	
			
	/* MAIN LOOP */		
	
	// LED indicator  
	if(socketStat == 0)
	{
		// scan H_SW0
		if (scan_input & BIT_SW_0) // switch up is high
		{
			if(**flipFlop** == 1)
			{
				led_display |= BIT_LED_0;	
				LCDHW_BackLight(true); // turn on LCD backlight
				
				// clear screen
				DRAW_Clear(&LcdCanvas, LCD_WHITE);

				// demo grphic api    
				DRAW_Rect(&LcdCanvas, 0,0, LcdCanvas.Width-1, LcdCanvas.Height-1, LCD_BLACK); // retangle
				DRAW_PrintString(&LcdCanvas, 40, 5, "Running...", LCD_BLACK, &font_16x16);
				
				DRAW_Refresh(&LcdCanvas); 
			}
			else
			{
				led_display &= ~BIT_LED_0;
				
				LCDHW_BackLight(false); // turn on LCD backlight
				DRAW_Clear(&LcdCanvas, LCD_WHITE);
				
				DRAW_Refresh(&LcdCanvas); 
			}	
		}			
	}
	else 
	{
		led_display |= BIT_LED_2;						
	}
			
	// to turn off system
	if (~scan_input & BIT_KEY_3) // key is active-low
	{
		led_display |= BIT_LED_3;			
		
		printf("bye\r");			
		iRunning = 0;	
		led_display &= ~BIT_LED_3;
	}
		
	// set led
	alt_write_word( ( virtual_base + ( ( uint32_t )( ALT_GPIO1_SWPORTA_DR_ADDR ) & ( uint32_t )( HW_REGS_MASK ) ) ), led_display );
	
	usleep(1000);
}

It seems that I cannot write to LCD and LED in the main loop. The LED is blinking but the LCD is not displaying text. I only can turn on and off the backlight. Does anyone has experience on this? Thanks.