Author Topic: STM32 SDADC not calibrating or converting  (Read 212 times)

0 Members and 1 Guest are viewing this topic.

Offline TheHolyHorse

  • Regular Contributor
  • *
  • Posts: 159
  • Country: se
  • You don't need to be confused, just understand it.
STM32 SDADC not calibrating or converting
« on: April 02, 2020, 03:47:53 pm »
Hi, so I'm working on a project which involves a STM32F373. Everything works (so far) except the SDADC and I can't find anything anywhere why it wouldn't work. Seems like I'm the only one with this problem as usual :-DD

On to the issue....

Everything initializes as it's supposed to and reading back the value of the registers shows the correct values.
If I start calibration it sets the CALIBIP bit in SDADC_ISR but it never clears it and never sets EOCALF so it's just stuck calibrating forever. Same thing happens if I start a conversion, it sets RCIP but never finishes.

Code: [Select]
RCC_APB2ENR |= SDADC1EN | SDADC2EN; // Enable SDADC1 and SDADC2 clock
PWR_CR = 0x600; // Enable SDADC1 and 2 power stuff

SDADC1_CR1 = 0;

DelayMillis(5);

SDADC1_CR2 = 1; //ADON

while (SDADC1_ISR & 0x8000); // Wait for stabilization

SDADC1_CR1 |= 0x80000000; //Enter init mode

while ((SDADC1_ISR & 0x80000000) == 0); //Wait

SDADC1_CR2 |= 0x480000;
SDADC1_CONF0R = 0x4C000000;
SDADC1_CONFCHR2 = 0;

SDADC1_CR1 ^= 0x80000000; // Leave init mode

while (SDADC1_ISR & 0x80000000); //Wait

SDADC1_CR2 |= 0x10; //Start calibration

while (SDADC1_ISR & 0x1000); //Wait for calibration to finish
« Last Edit: April 02, 2020, 03:54:24 pm by TheHolyHorse »
 

Offline AlexD

  • Newbie
  • Posts: 2
  • Country: at
Re: STM32 SDADC not calibrating or converting
« Reply #1 on: April 02, 2020, 03:59:09 pm »
Hi, what frequency is your SystemClock running at? The SDADC requires a clock between 500kHz and 6MHz, and it gets its clock from the SystemClock divided by SDPRE in the RCC_CFGR. Maybe the clock of the SDADC is too fast and thats why it doesn't work.
 

Offline TheHolyHorse

  • Regular Contributor
  • *
  • Posts: 159
  • Country: se
  • You don't need to be confused, just understand it.
Re: STM32 SDADC not calibrating or converting
« Reply #2 on: April 02, 2020, 04:00:46 pm »
Opps forgot to mention that, system clock is 48MHz and I'm using a division factor of 8 so that should equal to 6MHz.
 

Offline TheHolyHorse

  • Regular Contributor
  • *
  • Posts: 159
  • Country: se
  • You don't need to be confused, just understand it.
Re: STM32 SDADC not calibrating or converting
« Reply #3 on: April 03, 2020, 04:56:33 pm »
Looks like I'm just gonna have to ditch the SDADC. :-//
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf