STM32L433 adaption Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

STM32L433 adaption  Topic is solved

Postby Skadi » Thu Nov 23, 2017 10:34 am

Hi,

I'm planing to use the STM32L433 (48-Pin) for my next project. Until now I have used STM32F407 and STM32F429 in combination with ChibiOS (Chibi Studio), and I alway adapted consisting/included examples.

As there is no apropriate example for the STM32L433, I'm wondering what's the best way to adapt or create a new project including the STM32L433?

BR
Skadi

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32L433 adaption

Postby Giovanni » Thu Nov 23, 2017 1:00 pm

It depends on how much it is similar to the L432, if there are differences in the peripherals set then a new registry entry is required.

Giovanni

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32L433 adaption

Postby Skadi » Thu Nov 23, 2017 4:01 pm

Hi Giovanni,

according to the STM32L4 Series overview-table, they look identical, except the LCD display controller, which is included in the L433. But I'm not using a LCD display. I will have a look at the L432, and try to extend it from 32 pins to 48.

Thx
Skadi

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32L433 adaption

Postby Giovanni » Thu Nov 23, 2017 4:40 pm

Then you can use it as an L432.

Moving this in "feature requests" in order to add proper support in the L4 registry.

Giovanni

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32L433 adaption

Postby Skadi » Tue Nov 28, 2017 5:55 pm

Hi,

currently I'm adapting the RT-STM32L432KC-NUCLEO32 example. By having a look at the corresponding user manual (UM1956) of the STM32 Nucleo-32 board, it seems an external crystal oscillator (X1) is used (page 30).

I'm a little bit confused how to set up the internal oscillator correct. Do I have to change the sattings in the mcuconf.h file, and if so, how? Further I want to establish an USB connection, which should be possible with the internal RC48 MHz clock source (RC48 with clock recovery system (HSI48)).

Can anybody tell me, how to set up the internal oscillator(s) correct?

BR
Skadi

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32L433 adaption

Postby Giovanni » Tue Nov 28, 2017 6:48 pm

Hi,

There is no easy way to explain the mcuconf clock settings, all those definitions are found in the STM32 Reference Manual in the RCC (clocks) chapter, you need to configure those according to the RM.

When you compile the compilation will give errors in case you did something wrong, the checks are very secure. If you see errors post them here and we could help.

Giovanni

geoffrey.brown
Posts: 87
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 15 times

Re: STM32L433 adaption

Postby geoffrey.brown » Thu Nov 30, 2017 4:34 am

I find that the easiest way to figure out how to configure the clocks is to make a (fake) project using STM's cubemx tool and set up the clocks there. You can essentially read off the various PLL values and use them in the mcuconf.h file. The CRS system works well on the stm32l432. There's a thread somewhere in this forum where I explained how I did this. I'm not sure the changes I suggested for supporting HSI48 ever made it into the ChibiOS repo.

For using CRS, I include stm32l4xx_ll_crs.h from the ST HAL and initialize CRS as follows

#define RCC_APB1ENR_CRSEN ((uint32_t)0x08000000U)

rccEnableAHB1(RCC_APB1ENR_CRSEN,0);
rccResetAHB1(RCC_APB1RSTR1_CRSRST);

LL_CRS_SetSyncDivider(LL_CRS_SYNC_DIV_1);
LL_CRS_SetSyncPolarity(LL_CRS_SYNC_POLARITY_RISING);
LL_CRS_SetSyncSignalSource(CRS_CFGR_SYNCSRC_1);
LL_CRS_SetReloadCounter(
__LL_CRS_CALC_CALCULATE_RELOADVALUE(48000000,1000));
LL_CRS_SetFreqErrorLimit(34);
LL_CRS_SetHSI48SmoothTrimming(32);

LL_CRS_EnableAutoTrimming();
LL_CRS_EnableFreqErrorCounter();

I've used this in several projects, but I can't guarantee it's flawless.

Geoffrey

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32L433 adaption

Postby Skadi » Fri Apr 06, 2018 11:32 pm

Hi,

I finally found time to put my prototype into operation :lol: . I was able to create an USB connection by the use of the internal HSI48 RC clock source.

As a starting point I used the provided RT-STM32L432KC-NUCLEO32 - demo, which is included in the ChibiOS version 18.2. The clocks in my mcuconf.h file are set as following:

Code: Select all

#define STM32L4xx_MCUCONF

/*
 * HAL driver system settings.
 */
#define STM32_NO_INIT                       FALSE
#define STM32_VOS                           STM32_VOS_RANGE1
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0
#define STM32_HSI16_ENABLED                 TRUE
#define STM32_HSI48_ENABLED                 TRUE
#define STM32_LSI_ENABLED                   TRUE
#define STM32_HSE_ENABLED                   FALSE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_MSIPLL_ENABLED                FALSE
#define STM32_ADC_CLOCK_ENABLED             FALSE
#define STM32_USB_CLOCK_ENABLED             TRUE
#define STM32_SAI1_CLOCK_ENABLED            FALSE
#define STM32_SAI2_CLOCK_ENABLED            FALSE
#define STM32_MSIRANGE                      STM32_MSIRANGE_4M
#define STM32_MSISRANGE                     STM32_MSISRANGE_4M
#define STM32_SW                            STM32_SW_HSI16
#define STM32_PLLSRC                        STM32_PLLSRC_HSI16
#define STM32_PLLM_VALUE                    4
#define STM32_PLLN_VALUE                    40
#define STM32_PLLP_VALUE                    7
#define STM32_PLLQ_VALUE                    4
#define STM32_PLLR_VALUE                    2
#define STM32_HPRE                          STM32_HPRE_DIV1
#define STM32_PPRE1                         STM32_PPRE1_DIV1
#define STM32_PPRE2                         STM32_PPRE2_DIV1
#define STM32_STOPWUCK                      STM32_STOPWUCK_HSI16
#define STM32_MCOSEL                        STM32_MCOSEL_SYSCLK
#define STM32_MCOPRE                        STM32_MCOPRE_DIV1
#define STM32_LSCOSEL                       STM32_LSCOSEL_NOCLOCK
#define STM32_PLLSAI1N_VALUE                24
#define STM32_PLLSAI1P_VALUE                7
#define STM32_PLLSAI1Q_VALUE                2
#define STM32_PLLSAI1R_VALUE                6
#define STM32_PLLSAI2N_VALUE                72
#define STM32_PLLSAI2P_VALUE                7
#define STM32_PLLSAI2R_VALUE                6
#define STM32_USART1SEL                     STM32_USART1SEL_SYSCLK
#define STM32_USART2SEL                     STM32_USART2SEL_SYSCLK
#define STM32_USART3SEL                     STM32_USART3SEL_SYSCLK
#define STM32_UART4SEL                      STM32_UART4SEL_SYSCLK
#define STM32_UART5SEL                      STM32_UART5SEL_SYSCLK
#define STM32_LPUART1SEL                    STM32_LPUART1SEL_SYSCLK
#define STM32_I2C1SEL                       STM32_I2C1SEL_SYSCLK
#define STM32_I2C2SEL                       STM32_I2C2SEL_SYSCLK
#define STM32_I2C3SEL                       STM32_I2C3SEL_SYSCLK
#define STM32_LPTIM1SEL                     STM32_LPTIM1SEL_PCLK1
#define STM32_LPTIM2SEL                     STM32_LPTIM2SEL_PCLK1
#define STM32_SAI1SEL                       STM32_SAI1SEL_OFF
#define STM32_SAI2SEL                       STM32_SAI2SEL_OFF
#define STM32_CLK48SEL                      STM32_CLK48SEL_HSI48
#define STM32_ADCSEL                        STM32_ADCSEL_SYSCLK
#define STM32_SWPMI1SEL                     STM32_SWPMI1SEL_PCLK1
#define STM32_DFSDMSEL                      STM32_DFSDMSEL_PCLK1
#define STM32_RTCSEL                        STM32_RTCSEL_LSI

As can be seen, the external clocks HSE and LSE are disabled and the STM32_CLK48SEL is served by HSI48.

I installed the Virtual COM Port driver provided by ST. As USB connector I'm using a TYPE-B connector. So there is no ID Pin. The D+ pin (PA12) is connected by a 1.5 k resistor to the 3.3 V supply, VDD_USB (PIN 36) is hardwired to 3.3V.

I made a quick read/write test, and the communication works fine so far. As I'm using a 48-PIN package, the number of GPIO pins is "low" (compared to other packages ;) ). So I tried to use the pins PH0 and PH1 as OUTPUT pins. This should be possible according to the datasheet (5V tolerant I/O pins). This pins can be used to attach a crystal or oscillator to the controller. This external clock would act as HSE. As can be seen in the code above, the HSE and the LSE are disabled.

I wasn't able to set the pins PH0 and PH1 HIGH. Interestingly, for the pins PC14 and PC15, which are responsible for the LSE, it works fine. I defined the pins PH0, PH1, PC14 and PC15 in the board.h file as push-pull outputs. As it doesn't show any effect to the pins PH0 and PH1, I additionaly tried it by setting the corresponding registers in the main(void).

Code: Select all

  int main(void) {
  halInit();
  chSysInit();

  RCC->CR &= ~RCC_CR_HSEON;            // Disable HSE

  GPIOH -> MODER &= 0x00000005;         // PH0 & PH1: OUTPUT; default: 0x0000000F
  GPIOH -> OTYPER &= 0x00000000;        // Output push-pull (reset state); default: 0x00000000
  GPIOH -> ODR |= 0x00000003;           // set PH0 & PH1 initially HIGH
 
  ...}

I also disabled the HSE again, but it doesn't work.

Maybe someone already had the same problems?!

BR

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32L433 adaption

Postby Skadi » Thu Jun 14, 2018 8:14 am

Hi,

I'm still not able to use the pins PH0 and PH1 as GPIO pins, as stated in my previous post. Has anyone an idea how I can fix this or what I made propably wrong?

BR

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32L433 adaption

Postby Giovanni » Thu Jun 14, 2018 9:19 am

Hi,

Probably this should be asked in the ST forum, it looks like an HW behavior.

Giovanni


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 4 guests