2012-10-31 12:26 PM
Hi, i tried to use IAR example about LCD for use my display hd44780.
I connected 6 pin (RS,E,DB4,DB5,DB6,DB7) for use it on 4bit configuration (i'm sure that the connection is good cause i used that on my old arduino board). I only see first line of black simple, nothing else. Can someone help me with that code or link some other library that work good on stm32vldiscovery. Thx2012-11-02 02:55 AM
i tryed this change
//==========================================================================================
// System clocks configuration. //========================================================================================== void RCC_Configuration(void) { RCC_DeInit (); /* RCC system reset(for debug purpose)*/ RCC_HSEConfig (RCC_HSE_ON); /* Enable HSE *//* Wait till HSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);RCC_HCLKConfig (RCC_SYSCLK_Div1); /* HCLK = SYSCLK */
RCC_PCLK2Config (RCC_HCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK1Config (RCC_HCLK_Div2); /* PCLK1 = HCLK/2 */ RCC_ADCCLKConfig (RCC_PCLK2_Div4); /* ADCCLK = PCLK2/4 */*(vu32 *)0x40022000 = 0x01; /* Flash 2 wait state */
/* PLLCLK = 8MHz * 3 = 24 MHz */
RCC_PLLConfig (RCC_PLLSource_PREDIV1, RCC_PLLMul_3);RCC_PLLCmd (ENABLE); /* Enable PLL */
/* Wait till PLL is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);/* Select PLL as system clock source */
RCC_SYSCLKConfig (RCC_SYSCLKSource_PLLCLK);/* Wait till PLL is used as system clock source */
while (RCC_GetSYSCLKSource() != 0x08); }//==========================================================================================
// //========================================================================================== void delay_ms(int ms) { long i, tms; tms = 3000*ms; for(i=0;i<tms;i++); }//==========================================================================================
// //========================================================================================== void delay_us(int us) { long i, tus; tus = 3*us; for(i=0;i<tus;i++); } Now i havent black first line, the display seems to be on but nothing appear on the screen, someone have an idea?2012-11-02 02:57 AM
I need i think a new rcc configuration and a new delay function, from 24MHZ and not from 72MHZ
That is less critical IMHO. More important, the display starts up with a default configuration, which is, amongst others, 1 display line, display off, and 8-bit mode. I suggest to verify your driver code first, if you not yet did this. Single-step through the code that sets the control/data line, and verify all transitions and levels. A voltmeter suffices.
2012-11-02 04:05 AM
I think idea is that your delay function is not ''exact'' enough. You should make it with TIMER interrupt which would be much more reliable as what you've posted (unless you do it in assembler code, I doubt you can predict how many cycles that for loop will have)
void delay_ms(int ms) { long i, tms; tms = 9000*ms; for(i=0;i<tms;i++); }2012-11-07 09:05 AM
I'm trying to do what u suggest, i have this function in main
void Timer1IntrHandler (void) { // Clear update interrupt bit TIM_ClearITPendingBit(TIM1,TIM_FLAG_Update); Update = TRUE; } and this on stm32f10x_it.cvoid TIM1_UP_TIM16_IRQHandler(void)
{ Timer1IntrHandler();}
But when i compile i have this warning: Warning[Pe223]: function ''Timer1IntrHandler'' declared implicitly Some idea to fix it?2012-11-07 10:12 AM
But when i compile i have this warning:
Warning[Pe223]: function ''Timer1IntrHandler'' declared implicitly
Some idea to fix it? Yes because you're referring to a function in a different file, you'll need to use a prototype. extern void Timer1IntrHandler(void);
2012-11-07 10:38 AM
ok thanks
2012-11-08 06:26 AM
I need a clarification!
my driver for the LCD work well for 8-bit mode but works poorly for the 4-bit! there is nothing written on the datasheet for the 4-bit mode! I wanted to ask for your LCD as time allowed to pass between the first 4 bitsand the second 4 bits?for example, the set function does not work well! what is wrong?void LCD_FS(void){ Delay(5);LCD_PORT->LOW= RS; //RS RESETLCD_PORT->LOW= RW; //RW RESET// DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 // 0 0 1 1 1 1 0 0//most significant bitsLCD_PORT2->LOW = DB7; LCD_PORT2->LOW = DB6; LCD_PORT2->HIGH = DB5;LCD_PORT2->HIGH = DB4; LCD_En();//LB least significant bitsLCD_PORT2->HIGH = DB7; LCD_PORT2->HIGH = DB6; LCD_PORT2->LOW= DB5;LCD_PORT2->LOW= DB4;LCD_En();}2012-11-09 11:05 AM
Cause u need a delay imho before second section of command.
Try with void LCD_FS(void) { Delay(5); LCD_PORT->LOW= RS; //RS RESET LCD_PORT->LOW= RW; //RW RESET // DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 // 0 0 1 1 1 1 0 0 //most significant bits LCD_PORT2->LOW = DB7; LCD_PORT2->LOW = DB6; LCD_PORT2->HIGH = DB5; LCD_PORT2->HIGH = DB4; LCD_En(); //LB least significant bitsDelay(50); LCD_PORT2->HIGH = DB7; LCD_PORT2->HIGH = DB6; LCD_PORT2->LOW= DB5; LCD_PORT2->LOW= DB4; LCD_En(); } Verifty that u send enable pin UP when send command and low after u have send ur data ( i don't know if LCD_EN() do it, i just said to verify)2012-11-09 01:00 PM
I wait between sending the first and the second transmission, this is not the problem.
I can also send the data, and bring up ''Hello word'' but I can not change the settings of the LCD for example, I do not accept the command to have two lines on the LCD or the command to clear the LCD ''LCD CLEAR'' etc etc. .... so there must be a problem in the code to send commands .... the code is this: /*MAIN*/LCD_Start4();
LCD_PrintData4(Testo);
//*LCD.C*//
void LCD_Start(void){
EnableGpioDLcd();
EnableGpioELcd();
Delay(30); //Wait for VDD
LCD_command(0X3C); //Function set
Delay(39);
LCD_command(0X0C); //Display On Of
Delay(39);
LCD_command(0X01); //Clear
Delay(2);
LCD_command(0x06); //Mode Set
Delay(30);
LCD_command(0x02); //Home
Delay(100);
}
void LCD_Init(void){
Delay(15); //PRIMA RIPETIZIONE
LCD_PORT->LOW= RS;
LCD_PORT->LOW= RW;
LCD_command4(0x48);
LCD_En();
Delay(5); //SECONDA RIPETIZIONE
LCD_PORT->LOW= RS;
LCD_PORT->LOW= RW;
LCD_command4(0x48);
LCD_En();
Delay(1); //TERZA RIPETIZIONE
LCD_PORT->LOW= RS;
LCD_PORT->LOW= RW;
LCD_command4(0x48);
LCD_En();
}
void LCD_command4(unsigned char Char){
LCD_PORT->LOW=RS;
Delay(10);
if((Char&0x1)==0x1)
{
LCD_PORT2->HIGH=DB4;
}
else
{
LCD_PORT2->LOW=DB4;
}
if((Char&0x2)==0x2)
{
LCD_PORT2->HIGH=DB5;
}
else
{
LCD_PORT2->LOW=DB5;
}
if((Char&0x4)==0x4)
{
LCD_PORT2->HIGH=DB6;
}
else
{
LCD_PORT2->LOW=DB6;
}
if((Char&0x8)==0x8)
{
LCD_PORT2->HIGH=DB7;
}
else
{
LCD_PORT2->LOW=DB7;
}
LCD_En();
Delay(100);
}
void LCD_Write4(unsigned char Char){
LCD_PORT->HIGH=RS;
Delay(10);
if((Char&0x1)==0x1)
{
LCD_PORT2->HIGH=DB4;
}
else
{
LCD_PORT2->LOW=DB4;
}
if((Char&0x2)==0x2)
{
LCD_PORT2->HIGH=DB5;
}
else
{
LCD_PORT2->LOW=DB5;
}
if((Char&0x4)==0x4)
{
LCD_PORT2->HIGH=DB6;
}
else
{
LCD_PORT2->LOW=DB6;
}
if((Char&0x8)==0x8)
{
LCD_PORT2->HIGH=DB7;
}
else
{
LCD_PORT2->LOW=DB7;
}
LCD_En();
}
void LCD_PrintData4(unsigned char Vet[]){
int i=9;
for(i=0;i<
9
;i++){
LCD_Write4((Vet[i]>>4)&0x0F);
Delay(10);
LCD_Write4((Vet[i]&0x0F));
}
}
void LCD_Start4(void){
EnableGpioDLcd();
EnableGpioELcd();
LCD_PORT->LOW = DB3;
LCD_PORT->LOW = DB2;
LCD_PORT->LOW = DB1;
LCD_PORT->LOW = DB0;
LCD_Init();
Delay(15); //Wait for VDD
LCD_command4((0X3C>>4)&0x0F); //Function set
LCD_command4(0X3C&0x0F);
Delay(39);
LCD_command4((0X0C>>4)&0x0F); //Display On Of
LCD_command4(0X0C&0x0F);
Delay(39);
LCD_command4((0X01>>4)&0x0F); //Clear
LCD_command4(0X01&0x0F);
Delay(10);
LCD_command4((0X06>>4)&0x0F); //Mode Set
LCD_command4(0X06&0x0F);
Delay(30);
LCD_command4((0X02>>4)&0x0F); //Mode Set
LCD_command4(0X02&0x0F);
Delay(100);
}
2012-11-09 01:03 PM
unsigned char Testo[9]={'T','e','s','t','o',':','-',')',' '};