2025-04-26 3:40 PM - last edited on 2025-04-28 5:42 AM by Sarra.S
Hi All
I have a breakout board, I've been testing some ws2812 code , I'm using TIM1 with DMA + PWM
I developed the code on the G030, it's a 32 pin package.
I'm using internal clock and have it running at 48MHz for Timers.
Works has intended.
Switch to C011 in an 8 Pin package.
Created new project in MX and just copied over the code I added.
I'm using internal clock and have it running at 48MHz for Timers.
Code does not work. complies fine, but the leds not work.
In both porjects I am using TIM1 , configured the same way.
I don't have a Scope where I can view the PWM output
Question: Does anyone of a any differences between how TIM1 works between both MCU? I looked through AN5969 Migrating between STM32G0 and STM32C0 MCUs and nothing jumped out.
Can I use CudeMonitor to review the PWM?
Any suggestions would be highly appreciated.
Regards, Stephen
2025-04-28 5:55 AM
Hello @stevecimo,
The STM32C0 series and STM32G0 series are pin-to-pin compatible, using the same package ofc!
Are you using this package for STM32C011 and for the STM32G030?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-04-28 6:02 AM
It should work...if compiler shows no warnings...?
+
to check, the tim/pwm setting: just stop it in debug and look at sfr -> tim1 , to see, whats it doing:
2025-04-28 6:26 AM
Hello,
can you please share also your projects?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-04-28 2:09 PM
Hi Sarra
I'm using an 8 pin package for the C011 and a 32 pin package for the G030
Regards, Stephen
2025-04-28 2:13 PM
No warnings, compile is clean in both projects
I'm on my way to work, I'll see if I can run the debug checks in a few days, have to study for an Azure test tonight. ( at 58 years old and 40 years working in IT, work still wants me to do Azure test..I hate tests....)
2025-04-28 2:17 PM
happy to , has log has no one laugh's out loud at my coding :)
Bottom line, is I have made some 7 segment led displays 19mm x 12mm using ws2812 leds
2025-04-29 3:35 AM
basically I first create an array of color (rgb) data for 7 leds, in the correct order
color = ((LED_Data[i][1]<<16) | (LED_Data[i][2]<<8) | (LED_Data[i][3]));
then from this array , i create an second array to hold the pwm data to be sent via DMA.
for (int i=23 ; i>=0; i--)
{
if (color&(1<<i))
{
pwmData[index] = 40; // 2/3 60 using 48MHz clock with AAR of 60 800KHz
}
else pwmData[index] = 20; // 1/3 of 60
index++;
}
}
for (int i=0; i<50; i++)
{
pwmData[index] = 0; // add some zeros at the end to flag end of transmission
index++;
}
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)pwmData, index);
while (!datasentflag){};
datasentflag = 0;
}
This works fine with the G030, nothing or random leds light up with the C011
Both MCU are using a 48MHz timer clock. 0 Prescaler and an arr of 60 to give 800KHz timing
C011:
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 60-1;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
G030
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 60-1;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
On the G030 I us PLL to get a 48MHz clock (C011 runs 48MHz internal clock)
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 9;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV3;
2025-04-29 11:30 AM
There shouldn't be a difference at the HAL level.
Are the pins properly configured?
Same LEDs or other ones? Some are said to need a longer (300++ µs) reset pulse.
A $10 USB logic analyzer could be a great help here.
hth
KnarfB
2025-04-30 2:39 AM
This is my basic setup, I just swap the 2 break out boards, same leds , using a bench powersupply at 3.3 volts ,
I preformed all my original testing with the G030, with the C011 , I have only run basic led toggling code. before trying to move my code from G030 to it.
All done with the CubeIDE, just configured a new project for the C011
, Then used the IDE's compare file feature to code over my parts of the code from the G030 main.c, not using any libraries or extra .h .c files.....
Hmmm, maybe I should double check I have selected the right C011? apart from Flash sizes, is there any difference in timer operations between submodels to the same main MCU type?