STM32L471 PC14 PC15

mikroC, mikroBasic and mikroPascal for PRO ARM® MCUs, supporting STM32, Tiva, Kinetis, & CEC devices
Post Reply
Author
Message
Global_Industries
Posts: 6
Joined: 11 Apr 2021 16:39

STM32L471 PC14 PC15

#1 Post by Global_Industries » 12 Apr 2021 20:12

Hello

Have ported a project from STM32F411 to STM32L471, but PC14 and PC15 did not output anything.
Tried de-activate LSE oscillator with:
RCC_BDCR.LSEON = 0;
RCC_BDCR.LSEBYP = 0;
RCC_BDCR.LSERDY = 0;
No change

GPIO is configured as follow:
GPIO_Digital_Output(&GPIOC_BASE, _GPIO_CFG_SPEED_2MHZ | _GPIO_PINMASK_0 | _GPIO_PINMASK_1 | _GPIO_PINMASK_2 | _GPIO_PINMASK_3 | _GPIO_PINMASK_11 | _GPIO_PINMASK_12 | _GPIO_PINMASK_13 | _GPIO_PINMASK_14 | _GPIO_PINMASK_15);

HSE crystal is 8MHZ

Everything in my code is working excepted PC14 and PC15, these output drive TFT control line. (control line drived by PC11, PC12, PC13, PC14, PC15, PD2)
Data bus is on PORTB

only PC14 and PC15 did not output anything.



Project setting are:
MSI Oscillator ON
MSI PLL OFF
MSI Range by RCC_SR
range 6 around 4Mhz
HSI16 osc ON
No effect on HSI16
HSI16 is not enabled by hardware
HSE osc ON
HSE Crystal not bypassed
Clock Security ON
PLL ON
PLLSAI1 OFF
PLLSAI2 OFF
PLL as system clock
SYSCLK not divided
APB1 not divided
APB2 not divided
MSI selected as wakeup
MCO output disabled
MCO is divided by 1
HSE clock as PLL
PLLM =1
Main PLL Mult = 20
PLLSAI3CLK output disable
PLLP = 7
PLL48M1CLK disable
PLLQ = 2
LSI ON
range 6 around 4 MHz
VCORE 1.2V

PS did code test with STM32L471, but should use STM32L476 in production, should be same code?

PS2 ported my code to STM32L072 and work well, even with PC14 and PC15...

Thanks

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: STM32L471 PC14 PC15

#2 Post by filip.grujcic » 14 Apr 2021 08:16

Hello,

Does the same happen if you create a new project and only initialize PC14 and PC15 as digital output?

Regards,
Filip Grujcic

Global_Industries
Posts: 6
Joined: 11 Apr 2021 16:39

Re: STM32L471 PC14 PC15

#3 Post by Global_Industries » 14 Apr 2021 14:05

Hi Filip

Yes, tried with
GPIO_Config(&GPIOC_BASE, _GPIO_PINMASK_14 | _GPIO_PINMASK_15, _GPIO_CFG_MODE_OUTPUT | _GPIO_CFG_SPEED_2MHZ | _GPIO_CFG_OTYPE_PP);
GPIO_Set_Pin_Mode(&GPIOC_BASE, _GPIO_PIN_14 | _GPIO_PIN_15, _GPIO_CFG_MODE_OUTPUT | _GPIO_CFG_OTYPE_PP);
GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_14 | _GPIO_PINMASK_15);

None of these setting working

Suspect that LSE seem to take over anyway...

Over that, look like USART don't seem to work too..
EnableInterrupts(); // enable interrupts.
UE_USART2_CR1_bit = 1;
RE_USART2_CR1_bit = 1; //receiver enable
RXNEIE_USART2_CR1_bit = 1; //rx on
TXEIE_USART2_CR1_bit = 0; //tx off
NVIC_IntEnable(IVT_INT_USART2);

UE_bit = 1;
RE_bit = 1;
RXNEIE_bit = 1;
TXEIE_bit = 0;
NVIC_IntEnable(IVT_INT_USART1);

Same code work well will STM32L072, STM32F1XX and STM32F411, had to fix USART1 to USART to make it work on STM32L072..

Do you need my complete project? Can send it to you by email, can't post on forum since is a commercial project..

IDE is 6.2.0

Fred

Global_Industries
Posts: 6
Joined: 11 Apr 2021 16:39

Re: STM32L471 PC14 PC15

#4 Post by Global_Industries » 15 Apr 2021 21:31

Update...
Same code direct drop to a STM32L476, serial work as it should?!? Still nothing on STM32L471..
PC14 and PC15 work if BOOT0 is left open, BOOT0 to 0, still no output on PC14 PC15.

Anybody know how to force PC14 and PC15 as output with assembly? Maybe it could overwrite fuse setting for the GPIO? Really suspect that ME force these pins for LSE oscillator...

Thanks

Global_Industries
Posts: 6
Joined: 11 Apr 2021 16:39

Re: STM32L471 PC14 PC15

#5 Post by Global_Industries » 16 Apr 2021 15:52

Searched for hours in STM32L476 manual... Find this:

RCC_CIERbits.LSECSSIE = 0; //Disable LSE interupt
RCC_CIERbits.LSERDYIE = 0; //LSE ready interupt disable
RCC_CIFRbits.LSECSSF = 0; //LSE clock interrupt flag
RCC_CIFRbits.LSERDYF = 0; //LSE ready interrupt flag
RCC_BDCRbits.LSCOSEL = 0; //LSE clock out selection (LSI selected)
RCC_BDCRbits.LSECSSON = 0; //Clock check OFF
RCC_BDCRbits.LSECSSD = 0; //No clock faillure detect
RCC_BDCRbits.LSEON = 0; //LSE OFF
RCC_BDCRbits.LSCOEN = 0; //LS clock output disabled
RCC_BDCRbits.RTCEN = 0; //Clock disabled
RCC_BDCRbits.RTCSEL = 0; //No RTC Clock source

RCC_APB1ENR1bits.PWREN = 1; //Enable power
PWR_CR1bits.DBP = 1; //Enable acces power domain
RCC_BDCRbits.RTCEN = 0; //Disable RTC
//PWR_CR3bits.APC = 1; //

GPIOC_LCKRbits.LCK14 = 0; //Unlock pin
GPIOC_LCKRbits.LCK15 = 0;
/*GPIOC_MODER = 0xABFFFFFF; //Reset PortC
//GPIOC_MODERbits.MODE = 0x01; //PortC as output
GPIOC_BRRbits.BR14 = 1; //Reset portC
GPIOC_BRRbits.BR15 = 1; //Reset portC
GPIOC_OTYPERbits.OT14 = 0; //Set as output
GPIOC_OTYPERbits.OT15 = 0; */

Maybe close to something? Maybe doing something in the wrong order, still no output at PC14, PC15... Please ME guy, can you take a look at this?

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: STM32L471 PC14 PC15

#6 Post by filip.grujcic » 21 Apr 2021 11:54

Hello,

Our compiler does not force LSE to be on, you can clearly see that in the Edit Project window, in the list you can see all registers that are being written to in order to configure the clock.
Unfortunately, I do not have L471 MCU here and on all of our hardware we always use these pins for LSE oscillator, therefore I can only guess where the issue could be.

I suggest making a new project and then try setting the BDRST bit in the RCC_BDCR register to 1 in order to perform the backup domain reset.
After that use the usual code for configuring pins as digital output:
GPIO_Digital_Output(&GPIOC_BASE, _GPIO_PINMASK_14 | _GPIO_PINMASK_15);
GPIOC_ODR.B14 = 0;
GPIOC_ODR.B15 = 0;

Let me know what happens.

Regards,
Filip Grujcic

Global_Industries
Posts: 6
Joined: 11 Apr 2021 16:39

Re: STM32L471 PC14 PC15

#7 Post by Global_Industries » 21 Apr 2021 12:39

Hi Filip

Was not working, but found register to make it work.

Here how to unlock GPIO PC14 and GPIO PC15. At very beginning of my code:

RCC_APB1ENR1bits.PWREN = 1; //Enable power
PWR_CR1bits.DBP = 1; //Enable acces power domain
delay_ms(5);
RCC_BDCRbits.LSECSSD = 0; //No clock faillure detect
RCC_BDCRbits.LSECSSON = 0; //Clock check OFF
RCC_BDCRbits.LSEON = 0; //LSE OFF
RCC_BDCRbits.RTCEN = 0; //Disable RTC
RCC_BDCRbits.RTCEN = 0; //Clock disabled
GPIOC_LCKRbits.LCK14 = 0; //Unlock pin
GPIOC_LCKRbits.LCK15 = 0;

Then you can use:

GPIO_Digital_Output(&GPIOC_BASE, _GPIO_CFG_SPEED_2MHZ | _GPIO_PINMASK_13 | _GPIO_PINMASK_14 | _GPIO_PINMASK_15);

Tested on STM32L471 and STM32L476

Usart2 still not work on STM32L471, but I don't care, will use STM32L476 for the project...

Fred

Post Reply

Return to “ARM PRO Compilers”