Hi,
I finally found time to put my prototype into operation
. 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