2017-01-17 06:16 PM
Hello
I have project MP3 using STM32F030C8.
MP3 decoder using I2C interface and user key using ADC. So, beginning of my prototype use STM32L0 series, it already done and no problem at all. After that I change to STM32F030C8 then problem happen.
User key didn't work because ADC value are wrong (random). There is no different value when press each key. But if I disable MP3 (I2C) interface, ADC is works.
Here my block system
I attach my related code.
Thank you any clue I appreciate.
Edit : I checked ADC and DMA register by KEIL debugger, here the screenshoot
This is condition when I comment MP3 (i2c) code, Register value seem OK.
register DR value is FFF when no key press. And when I press each key, it give desired value.
And here normal condtion (MP3 I2C active).
Both ADC and DMA register value are absurd. Sometime it change to random value.
But MP3 function is works. Its like there is collision between I2C and ADC. ADC peripheral address suddenly change every time read and write data via I2C.
.This is very strange please help.
#adc #i2c2017-01-18 02:02 PM
I don't Cube and won't attempt to understand the code you posted, but my first rough guess is that this you have some runaway buffer index or pointer.
JW
2017-01-18 06:03 PM
Hello Jan
Thanks for reply. Should I move using std periperal library ?
Because this error very strange. I change I2C buffer size then suddenly when I place breakpoint at :
HAL_I2C_Master_Transmit(&I2CHandle,(uint16_t)LSI_ADDR_WR,(uint8_t *)temp, len_1 + len_2,1000)
also I place breakpoint inside HAL_I2C_Master_Transmit function then click run it didn't stop at second breakpoint. It go to HardFault_Handler().
HAL_driver sometime give me odd error.
2017-01-19 12:17 AM
I found solution but this is ugly solution. Since ADC DR register located at 0x40012440, then I trace memory using debugger it seem this address store ADC value correctly.
So I make pointer to that address then read pointer data everytime key bouncing occur.
uint32_t value = *(uint32_t*) 0x40012440;
But still I hope there is a good solution about my problem. Is this a reason why mostly people avoid HAL_Driver?
2017-01-19 01:31 AM
Should I move using std periperal library ?
I did not say that.
If you are seing variables to be overwritten unexpectedly, start from that. Can you use data breakpoints (i.e. breakpoints which stop when a memory position or range is read or written)? If yes, use them on those Cube 'device instance' structures which got overwritten and find out why are they overwritten.
JW
Because this error very strange. I change I2C buffer size then suddenly when I place breakpoint at :
HAL_I2C_Master_Transmit(&I2CHandle,(uint16_t)LSI_ADDR_WR,(uint8_t *)temp, len_1 + len_2,1000)
then click run it didn't go to function HAL_I2C_Master_Transmit.
HAL_driver sometime give me odd error.
Reply to this message by replying to this email, or go to the message on STMicroelectronics Community Start a new discussion in STM32 MCUs Forum by email or at STMicroelectronics Community Following STM32 MCUs Forum in these streams: Following This email was sent by STMicroelectronics Community because you are a registered user.
You may unsubscribe instantly from STMicroelectronics Community, or adjust email frequency in your email preferences
--- message truncated ---
2017-01-22 07:54 PM
No I cant find where that memory or position is overwritten. Because ADC structure is written on initialisation (which is beggining of run program) except interrupt flag