The blank screen might be due to the delay issue. Here is what you can do Put the code below in the LCD.c file 1. static uint32_t DWT_Delay_Init(void) { CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk; CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CTRL &= ~DWT_CTRL_CYCCNTENA_Msk; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; DWT->CYCCNT = 0; __NOP(); __NOP(); __NOP(); if(DWT->CYCCNT) { return 0; } else { return 1; } } void DWT_Delay_us(volatile uint32_t usec) { uint32_t clk_cycle_start = DWT->CYCCNT; usec *= (HAL_RCC_GetHCLKFreq() / 1000000); while ((DWT->CYCCNT - clk_cycle_start) < usec); } 2. Initialise the DWT in the starting inside the LCD_Init function DWT_Delay_Init(); 3. Now use DWT_Delay_us (time) ads the delay instead of the timer delay
Hi, I have a question, how can i continue printing automatically in the 2nd row without call lcd_put_cur(), if the word's lenght is more than 16 characters?
You can write another function for it. Inside that function, check how many charatcters has been written. Once the number crosses 16, call the lcd_put_cur to put the curser in the second row.
You need to use the custom characters and design the entire script yourself. I will do a video on custom characters soon, but don't expect me to design the entire varnmala.
Hello, I want to realize a project with FreeRTOS and multi tasking. I guees there will be some adaptations to make it non-blocking (non-blocking delays). Any advices on how to do it (for example can I use it with I2C without any difficulties?). I'm a newbie with STM, thanks for your answer.
Hello i am trying to follow your tutorial but i can´t get it to work. The screen turns on , but all that appears are black rectangles, as if all the lcd matrix was turned on at the same time. 1st question: In the code there is no reference to RW at all, it gets defined but you never set a value to it, ¿Does this matter? 2nd question: If the max clock speed of my microcontroller is 80Mhz and it runs at that speed in default, then there is no need to activate the ceramic clock, ¿Right?. I am just using the internal clock with a prescaler of 80-1. 3rd question: My LCD is a GDM 1602K, and in the datasheet it seems all the commands work exactly the same, but there is no reference to the initialization procedure, ¿Should i use the same one as you do? If you have any clue about what my problem could be, i would be more than greatfull.
1. The RW pin should be low for the write operations. So just connect it to the ground 2. You might need the microsecond delay. But if you don't know how to work with it, you can reduce the HCLK to 50 or something, and than just use the code simply without delay 3. All 1602 works with the same initialisation You might want to reduce the contrast if you are seeing the black boxes.
@@ControllersTech I will connect RW to ground, I forgot to mention that between all the black boxes there was half a second where i could see half a number form on the screen, so i dont think it is the contrast
@@ControllersTech I'm too facing the same problem, Rectangle boxes even after changing HCLK delay.......is there anything else I should do to make it work?
My maximum HCLK is 48 MHz so i tried some differents prescalers in the timer 1, and i remove the delay from send_to_display function. I also connected the RW pin in the GND. But doens´t work, do you know what could be? I am using a SRM32f072B Discovery board. Thanks.
Don't mess with prescalars. The purpose is to create delay in microsecond. First check what's the apb clock for the timer, that u are using. Let's say it 48, than use prescalar as 47. Also for 48 MHz hclk you don't need the delay. It will work without delay, although just introduce small delay in case of errors
Hi man, i got the same issue as you here. I use the same board and still getting a blank screen but I don't find the solution. Did you managed to make it working ? Thanks
I'm using a NUCLEO-F446RE but it doesn't work, the LCD lights up but it doesn't write. the Clock is 84MHz so i'm using a prescaler of 83, I also chaged the pins, i'm using PB8-PB9-PB10-PB12-PB13-PB14-PB15. Can you hel me?
You can use typecast to conver it to integer.. so it will convert to 100.. Or use some do while loop to check until the first number, other than 0 arrives. Then save the rest of the data into the buffer
hi,i use stm32f4 discovery and just light up,no letters or numbers at screen etc. apb2 bus 168Mhz, so i made it "168-1" ,presecaler is "0xffff-1".Other things same. I increased microsecond value step step such as 0,,20,50,80,130.. what should i do,any offer for me? thanks in advance
you mean "void send_to_lcd (char data, int rs)" that function delays right? i made clock bus 42Mhz and close delays in this function but still just light on. no letters and numbers
Can we use the same code in the keil software. Will it work like using STM32 Cube IDE for pin configuration and the code in the keil software that you explained here. Will it work?
Hello sir, I flash the same code in my lcd with stm32f103 the only difference that i have was pin use insist of PA4-PA7 i am using PA0-PA3 so i change configuration of lcd data and lcd cmd but that didn't work i use (cmd&0xf0)right shift 4 . please suggest what possible error i am doing
You can't use PA0 to PA3. In 4 bit mode, you have to use the pins 4 to 7. Please read the datasheet before experimenting.. You can use 8 bit mode and use all the pins(0 to 7).
No. The code is written to take take of individual pins. Also that's the point of defining them in the beginning, so that we don't have to deal with them afterwards
Thank you for this ...your videos are very helpful . i am having difficulty passing numeric values. Kindly advise. i tried sprintf to char array variable , but no success. kindly provide sample code to display integer variable e.g 1234. thank you.
The blank screen might be due to the delay issue. Here is what you can do
Put the code below in the LCD.c file
1. static uint32_t DWT_Delay_Init(void)
{
CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk;
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CTRL &= ~DWT_CTRL_CYCCNTENA_Msk;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
DWT->CYCCNT = 0;
__NOP();
__NOP();
__NOP();
if(DWT->CYCCNT)
{
return 0;
}
else
{
return 1;
}
}
void DWT_Delay_us(volatile uint32_t usec)
{
uint32_t clk_cycle_start = DWT->CYCCNT;
usec *= (HAL_RCC_GetHCLKFreq() / 1000000);
while ((DWT->CYCCNT - clk_cycle_start) < usec);
}
2. Initialise the DWT in the starting inside the LCD_Init function
DWT_Delay_Init();
3. Now use DWT_Delay_us (time) ads the delay instead of the timer delay
Absolutely works! Changed pins, and work at once without errors!
You saved my life, thank you very much online stranger.
Helpful video as always :)
Thank you so much!!!
I got my nucleo to run the arduino lcd shield
you are king of stm on the toutube thank you and ı so like your site;
thanks sir thanks
Jan 2023 - it still works
Well Done! Nice and complete.
YOU are perfect as usual
Great video, thanks for the information
Hello, would you tell me how can I download the library of the project I didn't find it on your website!
Hi, I have a question, how can i continue printing automatically in the 2nd row without call lcd_put_cur(), if the word's lenght is more than 16 characters?
You can write another function for it. Inside that function, check how many charatcters has been written. Once the number crosses 16, call the lcd_put_cur to put the curser in the second row.
hello, your videos are been a gem to us, I tried the same code but I'm just getting blank screen
yeah me too.
Thank you sir for the wonderful tutorial. Can you make a video on Devanagari display in same set up?
You need to use the custom characters and design the entire script yourself.
I will do a video on custom characters soon, but don't expect me to design the entire varnmala.
@@ControllersTech 😅
gracias desde colombia , greate job!!
Thank you for all your great tutorials.
How do you control the LCD contrast? I don't see any potentiometer on your breadboard. Is there an other way?
I didn't controlled the contrast in that. Just connected the pin to 3.3v. I don't use the lcd without i2c. This setup was just done for the video
@@ControllersTech Thanks for the quick reply:)
Thanks for you great best..that very useful totuirial ..the LCD work on 3.3 volt or 5 volt power supply.??
5v
@@ControllersTech this code can use with STML xxxx ?
Yeah why not..
That good..because we use ATM32L ultra low power sreies....thanks so much for your reply..
nice and great video
Hello,
I want to realize a project with FreeRTOS and multi tasking. I guees there will be some adaptations to make it non-blocking (non-blocking delays). Any advices on how to do it (for example can I use it with I2C without any difficulties?).
I'm a newbie with STM, thanks for your answer.
Yes you can use i2c. Check another video for i2c and lcd
Thanks You! One question, if I would like to print a variable, how can I do?
By converting it to character
Hello i am trying to follow your tutorial but i can´t get it to work. The screen turns on , but all that appears are black rectangles, as if all the lcd matrix was turned on at the same time.
1st question: In the code there is no reference to RW at all, it gets defined but you never set a value to it, ¿Does this matter?
2nd question: If the max clock speed of my microcontroller is 80Mhz and it runs at that speed in default, then there is no need to activate the ceramic clock, ¿Right?. I am just using the internal clock with a prescaler of 80-1.
3rd question: My LCD is a GDM 1602K, and in the datasheet it seems all the commands work exactly the same, but there is no reference to the initialization procedure, ¿Should i use the same one as you do?
If you have any clue about what my problem could be, i would be more than greatfull.
1. The RW pin should be low for the write operations. So just connect it to the ground
2. You might need the microsecond delay. But if you don't know how to work with it, you can reduce the HCLK to 50 or something, and than just use the code simply without delay
3. All 1602 works with the same initialisation
You might want to reduce the contrast if you are seeing the black boxes.
@@ControllersTech I will connect RW to ground, I forgot to mention that between all the black boxes there was half a second where i could see half a number form on the screen, so i dont think it is the contrast
Ok.. it must be the timing than.
Either create that microsecond delay, and use it where I have commented it out.
Or reduce the HCLK to 50 MHz or so
@UCkdqtSMnhYuMsJkyHOxiPZQ I will try reducing the clock speed to 50mhz to see if timing is the problem
@@ControllersTech I'm too facing the same problem, Rectangle boxes even after changing HCLK delay.......is there anything else I should do to make it work?
everything is correct but your code is not working. I set up the lcd and pinouts as well everything is correct.
Same... In my case STM32 CUBE IDE gave the message " ./Core/Src/sysmem.c:63:1: error: unknown type name 'caddr_t'" when I tried to compile :(
My maximum HCLK is 48 MHz so i tried some differents prescalers in the timer 1, and i remove the delay from send_to_display function. I also connected the RW pin in the GND. But doens´t work, do you know what could be? I am using a SRM32f072B Discovery board. Thanks.
Don't mess with prescalars. The purpose is to create delay in microsecond. First check what's the apb clock for the timer, that u are using.
Let's say it 48, than use prescalar as 47.
Also for 48 MHz hclk you don't need the delay. It will work without delay, although just introduce small delay in case of errors
Hi man, i got the same issue as you here. I use the same board and still getting a blank screen but I don't find the solution. Did you managed to make it working ?
Thanks
I have some warning in code row 44 to 58 "enumerated type mixed with another type", how fix it?
need more info. What's in those lines ?
@@ControllersTech sorry, that warning from my compiler (keil), what compiler do u use?
Hi
I'am confused.Bit DB7 of DDRAM is HIGH.That is hex 0x80 but DDRAM adress is 0x00 to 0x4F. Is this possible?
Thank you
I'm using a NUCLEO-F446RE but it doesn't work, the LCD lights up but it doesn't write. the Clock is 84MHz so i'm using a prescaler of 83, I also chaged the pins, i'm using PB8-PB9-PB10-PB12-PB13-PB14-PB15. Can you hel me?
well i have 446RE and it works pretty well. SOMETHING WRONG FROM YOUR END
does this code works for 20*4 lcd??
Grounding the rw pin means only write! Is this correct?
Yes
I’ve not been able to write on my 1602 lcd. I followed the tutorial but no luck.
Hello
In 100,000 units, less than 1 is displayed as zero, and how do I make zero invisible?
I don't understand what you are asking..
Plz explain
@@ControllersTech Decimal Display 000100 > 100 , 000123 > 123
So you want to display 000100 as 100 ?
Or as 000100?
@@ControllersTech Yes, that's right.
Please tell me how to mark 000100 as 100.
You can use typecast to conver it to integer.. so it will convert to 100..
Or use some do while loop to check until the first number, other than 0 arrives. Then save the rest of the data into the buffer
hi,i use stm32f4 discovery and just light up,no letters or numbers at screen etc. apb2 bus 168Mhz, so i made it "168-1" ,presecaler is "0xffff-1".Other things same. I increased microsecond value step step such as 0,,20,50,80,130.. what should i do,any offer for me? thanks in advance
Try reducing your clock below 72 MHz and don't use any delay and check..
you mean "void send_to_lcd (char data, int rs)" that function delays right? i made clock bus 42Mhz and close delays in this function
but still just light on. no letters and numbers
read the pinned comment..
or contact on discord
@@ControllersTech i read but no solution. and i wrote stm32f4 channel on discord
Can we use the same code in the keil software. Will it work like using STM32 Cube IDE for pin configuration and the code in the keil software that you explained here. Will it work?
Yeah it can work with any ide..
If i want to make a digital clock in lcd how can i do it?
th-cam.com/video/LBD7noDBnlc/w-d-xo.html
Can I use this for 16x4 lcd display,, plz reply
i only see boxes with this code nothing else happens
Sir you need to use a potentiometer at V0 pin to adjust the contrast of lcd
Hello sir,
I flash the same code in my lcd with stm32f103 the only difference that i have was pin use insist of PA4-PA7 i am using PA0-PA3 so i change configuration of lcd data and lcd cmd but that didn't work i use (cmd&0xf0)right shift 4 . please suggest what possible error i am doing
You can't use PA0 to PA3. In 4 bit mode, you have to use the pins 4 to 7.
Please read the datasheet before experimenting..
You can use 8 bit mode and use all the pins(0 to 7).
Hi, i am not saying about the lcd pin i am talking about port pinof stm32f103
Oh my bad.
Don't change command.. just define new pins and leave everything as it is
but you have taken pa4-pa7 data pin and i have pa0-pa3 as my data pins so does we need to changes for the nibbles in cmd and data
No. The code is written to take take of individual pins. Also that's the point of defining them in the beginning, so that we don't have to deal with them afterwards
whare are lcd.h and lcd.c files ( libraries files )
Download the code from the link in the description
Gan agar bisa berjalan text nya gimana (running text)
Where are all my fellow students from Stellenbosch university watching this for E-deign? 😂😂
Right here👋
Got any tips? Send code😭😭
hey, I'm back at it again. @@nicomartin5584
@@fugitive6549 lol..2 years are u doing electrical engineering?
hello . your video is great. but can you give me lirbary of lcd as video
Thank you for this ...your videos are very helpful . i am having difficulty passing numeric values. Kindly advise. i tried sprintf to char array variable , but no success. kindly provide sample code to display integer variable e.g 1234. thank you.
Char num_arr[4];
Uint16_t num = 1234;
Sprintf (num_arr, "%u", num);
That's all. If it gives error with %u, try changing uint16_t to unsigned int..
how to dark theme
Get the darkest dark theme from eclipse marketplace
Noooooooo AI speak
I am a beginner in stm32 and using F303RE. Do I change include to my specific board, referring to stm32f1xx_hal.h? keep getting "unresolved inculsion"
Yes change it to f3xx_hal.h