2013-07-21 02:58 PM
Hi,
use
the
STM32F103
microcontroller
for my thesis
.The firmware
uses different
Timer,
2
ADC
, SPIand some
GPIOs
.Until yesterday
everything worked
perfectly
but since I
decided to use
two timers
in
master / slave mode
,to generate two
PWM
, I get thefollowing error
in Keil
: Error-Flash-download-failed-
Cortex-
M0. After downloading of the
new firmware, the microcontroller is
working properly
and is able to
perform different tasks
, but whenI want to load
a new firmware
I get
the error: ''
Error-
Flash-download-failed-
Cortex-
M0''.I checked
if the download algorithm
isthe correct one.
I deleted
the target and
compiled all the
code
in Keil
.For now,
the only way to
retrieve my
board is
replaced
themicrcontrollore
with another
oneand not
load the latest firmware
.This is the function
that I added
: void STM32_PumpEnable(unsigned short DutyCycle,unsigned short FullPeriod,u16presc) 2 { 3 4 /*Configurazione GPIO PIN_POMPA_PIEZO1*/ 5 GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP; 6 GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; 7 GPIO_InitStructure.GPIO_Pin=PIN_POMPA_PIEZO1; 8 GPIO_Init(BANCO_POMPA,&GPIO_InitStructure); 9 10 11 /* Uscita Canale 3 Negato */ 12 GPIO_N_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP; 13 GPIO_N_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; 14 GPIO_N_InitStructure.GPIO_Pin=GPIO_Pin_1; 15 GPIO_Init(GPIOB,&GPIO_N_InitStructure); 16 17 /* Inizializzazione Timer8 - Piezo 1 */ 18 TIM_TimeBaseStructure.TIM_Period=FullPeriod; 19 TIM_TimeBaseStructure.TIM_Prescaler=presc; //0x80 20 TIM_TimeBaseStructure.TIM_ClockDivision=0x00; //0x00 21 TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up; 22 /* Deinitializes the TIMx peripheral registers to their default reset values. */ 23 TIM_DeInit(TIM_PWM_POMPA); 24 /* Initializes the TIMx Time Base Unit peripheral according to the specified parameters in the TIM_TimeBaseInitStruct. */ 25 TIM_TimeBaseInit(TIM_PWM_POMPA,&TIM_TimeBaseStructure); 26 /* Enables or disables TIMx peripheral Preload register on ARR. */ 27 /* Updata timer when overflow occur */ 28 TIM_ARRPreloadConfig(TIM_PWM_POMPA,ENABLE); 29 /* Configurazione Canale PIN_POMPA_PIEZO1*/ 30 TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_PWM1; 31 TIM_OCInitStructure.TIM_Pulse=DutyCycle; 32 TIM_OCInitStructure.TIM_OutputState=TIM_OutputState_Enable; 33 TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_Low; 34 TIM_OCInitStructure.TIM_OCIdleState=TIM_OCIdleState_Reset; 35 TIM_OC1Init(TIM_PWM_POMPA,&TIM_OCInitStructure); 36 TIM_OC1PreloadConfig(TIM_PWM_POMPA,TIM_OCPreload_Enable); 37 TIM_OC1FastConfig(TIM_PWM_POMPA,TIM_OCFast_Disable); 38 39 /*Sets or Resets the TIMx Master/Slave Mode.*/ 40 TIM_SelectMasterSlaveMode(TIM_PWM_POMPA,TIM_MasterSlaveMode_Enable); 41 /*Enables or Disables the TIMx Update event.*/ 42 TIM_UpdateDisableConfig(TIM_PWM_POMPA,ENABLE); 43 /*Selects the TIMx Trigger Output Mode.*/ 44 TIM_SelectOutputTrigger(TIM_PWM_POMPA,TIM_TRGOSource_Update); 45 46 47 /*Configurazione GPIO PIN_POMPA_PIEZO2*/ 48 GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP; 49 GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; 50 GPIO_InitStructure.GPIO_Pin=GPIO_Pin_1; 51 GPIO_Init(GPIOB,&GPIO_InitStructure); 52 /* Inizializzazione Timer3 - Piezo 2 */ 53 TIM_TimeBaseStructure.TIM_Period=FullPeriod; 54 TIM_TimeBaseStructure.TIM_Prescaler=presc; //0x80 55 TIM_TimeBaseStructure.TIM_ClockDivision=0x00; //0x00 56 TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up; 57 /* Deinitializes the TIMx peripheral registers to their default reset values. */ 58 TIM_DeInit(TIM3); Page 1 Funzione.c 21/07/2013 59 /* Initializes the TIMx Time Base Unit peripheral according to the specified parameters in the TIM_TimeBaseInitStruct. */ 60 TIM_TimeBaseInit(TIM3,&TIM_TimeBaseStructure); 61 /* Enables or disables TIMx peripheral Preload register on ARR. */ 62 /* Updata timer when overflow occur */ 63 TIM_ARRPreloadConfig(TIM3,ENABLE); 64 65 /* Configurazione Canale PIN_POMPA_PIEZO2*/ 66 TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_PWM1; 67 TIM_OCInitStructure.TIM_Pulse=DutyCycle; 68 TIM_OCInitStructure.TIM_OutputState=TIM_OutputState_Enable; 69 TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_Low; 70 TIM_OCInitStructure.TIM_OCIdleState=TIM_OCIdleState_Reset; 71 TIM_OC4Init(TIM3,&TIM_OCInitStructure); 72 TIM_OC4PreloadConfig(TIM3,TIM_OCPreload_Enable); 73 TIM_OC4FastConfig(TIM3,TIM_OCFast_Enable); 74 // TIM_OC3Init(TIM_PWM_POMPA, &TIM_OCInitStructure); 75 // TIM_OC3PreloadConfig(TIM_PWM_POMPA, TIM_OCPreload_Enable); 76 // TIM_OC3FastConfig(TIM_PWM_POMPA, TIM_OCFast_Enable); 77 78 /*Selects the TIMx Slave Mode.*/ 79 TIM_SelectSlaveMode(TIM3,TIM_SlaveMode_Trigger); 80 /*Selects the Input Trigger source*/ 81 TIM_SelectInputTrigger(TIM3,TIM_TS_ITR1); 82 83 84 TIM_CtrlPWMOutputs(TIM_PWM_POMPA,ENABLE); 85 TIM_Cmd(TIM_PWM_POMPA,ENABLE); 86 87 }This problem
may be due to
a bug
in the libraries
?
Can you help me
to solve this problem?
Thanks to all
Hello
#stm32 #output #discovery #pwm2013-07-21 05:08 PM
This problem
may be due to
a bug
in the libraries
?That's a convenient thesis, but probably wrong. Most of these problem come from a failure to appreciate what the silicon will do by the user. It's odd it would be complaining about a M0 with an M3 part, are you sure the target/algorithm settings are correct? If it's a code/pin issue you could set BOOT0 High at boot to run the System Loader instead, and this would save having to physically remove/replace the part. Note there is a source code pasting tool ''Paintbrush [<>]'' icon. Post code with this, without line numbers and with #defines would enable a more clear analysis of what might be going on. You can certainly break the SWD/JTAG interface by programming the GPIO pins incorrectly, with DMA, and low-power WFI loops, among other things.