cancel
Showing results for 
Search instead for 
Did you mean: 

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

Emanuelo
Associate II

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;
}

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

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

View solution in original post

4 REPLIES 4
Piranha
Chief II

You have forgot the delay between the dots and dashes.

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

Piranha
Chief II

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

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