Skip to main content
Emanuelo
Associate
October 9, 2022
Solved

STM32H755ZI-Q Small problem with Led not working as it should.

  • October 9, 2022
  • 4 replies
  • 1135 views

I'm trying to blink variation of morze code with specific string on yellow led, but the led just turns on and stays on for a little bit and then turns off.

When I try to debug it step by step it works as it should, but the moment I press run, it does the same think. If anyone can shed some light on this, I would really appreciate it!

Thank you!

 char* name= "text";
 char *string;
 /* USER CODE END 2 */
 
 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
 while (1)
 {
 	 for(;*name!= '\0';name++) {
 		 string = morze(*name);
 		 for(int i = 0;string[i] != '\0';i++) {
 			 HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_1);
 			 if(string[i] == '.'){
 				 HAL_Delay(500);
 			 }else if(string[i] == '-') {
 				 HAL_Delay(1000);
 			 }else {
 				 int a = 0;
 			 }
 			 HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_1);
 		 }
 	 }
 /* USER CODE END WHILE */
 
 /* USER CODE BEGIN 3 */
 }
 
char* morze(char a)
{
 switch (a) {
 case 'x':
 return "-..-";
 case 'e':
 return ".";
 case 't':
 return "-";
 default:
 	break;
 }
 return NULL;
}

This topic has been closed for replies.
Best answer by Piranha

Then it's the wrong place. You have to wait for a pause in a code position, where the LED is off!

4 replies

Piranha
Principal III
October 9, 2022

You have forgot the delay between the dots and dashes.

Emanuelo
EmanueloAuthor
Associate
October 9, 2022

if I add delay there it does the same think just for longer

Piranha
PiranhaBest answer
Principal III
October 9, 2022

Then it's the wrong place. You have to wait for a pause in a code position, where the LED is off!

Emanuelo
EmanueloAuthor
Associate
October 9, 2022

Yea, I'm dumb, I was putting it in wrong place.