2012-08-10 12:44 AM
Hello,
I'm working on a custom board around a STM32F051K8. I was playing with it for 2 or 3 days, everything was fine, then without moving it or something, it stopped responding to SWD interface. The previous code is still running in the MCU. The ST Link V2 + ST Link Utilities says not target, JLink manage to stop the core apparently (I have a LED kind of blinking that stops when JLink try to program) but says internal unknown error (the magic one !). At the time it stopped working, I was coding some DMA stuff for PWM. I checked connections, everything is ok. Any hint on what can be wrong ? I know sometimes on STM32F205 when you cannot access the core via JTAG, you can run it in builtin bootloader mode to get access to it, on this board the BOOT0 pin is tied to GND so it would be difficult to do it (I'll try if I can't find another solution). Thomas.2012-09-21 07:57 AM
Ok it broke under the epoxy ...
Anyway, here is my code right now :int i;
for(i = 0; i<
DMA_BUFFERSIZE
; i++)
m_dmaBuffer[i] = 800 - i*10;
GPIO_InitTypeDef gpio_init;
TIM_TimeBaseInitTypeDef tim_init;
TIM_OCInitTypeDef oc_init;
DMA_InitTypeDef dma_init;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM16, ENABLE);
SYSCFG_DMAChannelRemapConfig(SYSCFG_DMARemap_TIM16, DISABLE); // TIM16 DMA on DMA Channel 3.
gpio_init.GPIO_Mode
=
GPIO_Mode_AF
;
gpio_init.GPIO_Pin
=
GPIO_Pin_8
;
gpio_init.GPIO_PuPd
=
GPIO_PuPd_NOPULL
;
gpio_init.GPIO_Speed
=
GPIO_Speed_50MHz
;
gpio_init.GPIO_OType
=
GPIO_OType_PP
;
GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_2);
GPIO_Init(GPIOB, &gpio_init);
tim_init.TIM_ClockDivision
=
TIM_CKD_DIV1
;
tim_init.TIM_CounterMode
=
TIM_CounterMode_Up
;
tim_init.TIM_Prescaler
=
15
;
tim_init.TIM_Period
=
0xFFF
;
tim_init.TIM_RepetitionCounter
=
1
;
TIM_TimeBaseInit(TIM16, &tim_init);
oc_init.TIM_OCMode
=
TIM_OCMode_PWM1
;
oc_init.TIM_OutputState
=
TIM_OutputState_Enable
;
oc_init.TIM_OCPolarity
=
TIM_OCPolarity_High
;
oc_init.TIM_Pulse
=
0xFFF
>>1;
TIM_CtrlPWMOutputs(TIM16, ENABLE);
TIM_ARRPreloadConfig(TIM16, ENABLE);
TIM_OC1PreloadConfig(TIM16, TIM_OCPreload_Enable);
TIM_OC1Init(TIM16, &oc_init);
TIM_DMAConfig(TIM16, TIM_DMABase_ARR, TIM_DMABurstLength_2Transfers);
TIM_DMACmd(TIM16, TIM_DMA_Update, ENABLE);
TIM_Cmd(TIM16, ENABLE);
dma_init.DMA_PeripheralBaseAddr = (unsigned int) (&(TIM16->DMAR));
dma_init.DMA_MemoryBaseAddr = (unsigned int) (m_dmaBuffer);
dma_init.DMA_DIR = DMA_DIR_PeripheralDST;
dma_init.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
dma_init.DMA_MemoryInc = DMA_MemoryInc_Enable;
dma_init.DMA_PeripheralDataSize = DMA_MemoryDataSize_HalfWord;
dma_init.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
dma_init.DMA_Mode = DMA_Mode_Normal;
dma_init.DMA_Priority = DMA_Priority_Low;
dma_init.DMA_M2M = DMA_M2M_Disable;
dma_init.DMA_BufferSize = DMA_BUFFERSIZE;
DMA_Init(DMA1_Channel3, &dma_init);
If I remove the call to DMA_Init it does work and output PWM. As soon as the DMA_Init is in the loop, it stops, even id I don't call the DMA_Cmd to enable it.
Thomas.
2012-09-21 10:28 AM
Hello,
I started again from almost zero and somehow got it to work (there must be some conflict with another part of the code, I'll check later when this is working). Now I'm facing a weird problem ... it seems the values I send to DMA are not correctly aligned or something. Main clock is 48MHz. Timer clock is 3MHz (prescaler = 15) If I set ARR = 250 through DMA, I should have a frequency of 3MHz/250 = 12KHz but the resulting frequency is 46Hz approx, which is about 255 times slower ! The same ratio applies everytime. If I set ARR = 260 then there is no more pulse (CCR1 = 10). I'm transfering 3 unsigned short values at a time to ARR, RCR and CCR1, RCR is always 0. Any idea ? Thomas.2012-09-24 11:57 AM
Hello,
I really need support on this one. I opened a technical support ticket but no reply yet. Is there any better way to get support from ST ? Thomas.2012-10-01 03:59 AM
Hello,
Do you know a way to get support from ST ? I tried anything I found, never had a reply. That is really annoying ... buying thousands of parts and they can't provide ANY technical support for their devices ????? I have a whole project waiting on (probably) a simple reply from a tech support. Thomas.2012-10-01 04:00 AM
Hello,
Do you know a way to get support from ST ? I tried anything I found, never had a reply. That is really annoying ... buying thousands of parts and they can't provide ANY technical support for their devices ????? I have a whole project waiting on (probably) a simple reply from a tech support. Thomas. PS : plus the forum which is complete crap and crashes 75% of the time ...2012-10-01 05:06 AM
Do you know a way to get support from ST ?
Usually through the FAE and regional sales guys, both at ST and the distributor level. Practically zero official support on the forum. I'll report the post and see if that gets us anywhere.