genericSTM32F405RG serial print output

Post here all questions related to STM32 core if you can't find a relevant section!
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: genericSTM32F405RG serial print output

Post by hobbya »

@ag123
Thanks for your suggestions.

What puzzled me was that with the same connection untouched, both blink and serial worked if I chose the board as Adafruit Feather F405 or Generic F407VE. It just would not work if I chose it as Generic F405RG.

Code: Select all

#define LED PC1
HardwareSerial Serial6(PC7, PC6);

void setup()
{
  Serial6.begin(9600);   // set to 14400 if choosing Feather F405 which assumes 12MHz clock
  pinMode(LED, OUTPUT);
}

void loop()
{
  Serial6.print("loop test");
  digitalWrite(LED, HIGH);
  delay(250);		// actual blink period is 0.375s if choosing Feather F405 since my board has 8MHz clock
  digitalWrite(LED, LOW);
  delay(250);
}
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: genericSTM32F405RG serial print output

Post by ag123 »

to troubleshoot this, define a variable in the variant include and try to test that
or define a function in both the variant include and cpp file and try to call it
the 'generic' variants based on what i saw isn't simply stm32fxxyy, below the soc sku, there is normally a specific_board.h file.
that could explain why 'generic' didn't work, it may need its own board definitions.
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: genericSTM32F405RG serial print output

Post by hobbya »

Indeed there is discrepancy in the variant.cpp file for Generic F4x5RG.

Code: Select all

// Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers
  RCC_ClkInitStruct.ClockType      = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource   = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider  = RCC_SYSCLK_DIV1;         // 168 MHz
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;           // 42 MHz
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;           // 84 MHz
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
    return 0; // FAIL
  }
Changing FLASH_LATENCY_1 to FLASH_LATENCY_5 solves my problem.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: genericSTM32F405RG serial print output

Post by fpiSTM »

@hobbya

It seems you used the core version 1.9.0. Try the 2.0.0 the Flash latency has the correct value.
Note that by default the generic F405RE uses the HSI clock.

I've retested with an Adafruit F405RG. With both variant Adafruit one (using HSE) and Generic using HSI.
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: genericSTM32F405RG serial print output

Post by hobbya »

Thanks for re-testing. Indeed this has been fixed in core 2.0.0.

https://github.com/stm32duino/Arduino_C ... /pull/1174

I would have found the fix earlier if I was wise enough to search for "F4x5RG" instead of "F405RG".
Post Reply

Return to “General discussion”