cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476 USART 3

shingadaddy
Senior
Posted on March 15, 2016 at 23:44

The original post was too long to process during our migration. Please click on the attachment to read the original post.
9 REPLIES 9
Amel NASRI
ST Employee
Posted on March 16, 2016 at 15:55

Hi shingadaddy,

What is about the file stm32l4xx_it.c? did you updated it to support USART3 interrupt request?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

shingadaddy
Senior
Posted on March 16, 2016 at 16:52

Hi Mayla and thanks so much for your response. I'm still pouring over the datasheet and user manual for what I may have missed.

Actually I am NOT too interested *yet* in getting INTERRUPT activity working on USART3. I am trying to establish BASIC CONTROL of pin PC4 (pin24). I am simply trying to toggle PC4 (pin24) by setting and clearing the TE (TRANSMIT ENABLE) bit on USART3.This is to prove I have control over the pin via USART3 means. And this TOGGLE TEST is functional on USART 1 and the documentation on the device backs up that functionality. I am pretty sure the GPIO is configured correct because pin 24 goes HIGH when I configure it and it is LOW if I don't.

It honestly acts like I don't have one of the myriad clock sources switched on correctly and my suspicions are driven by the USER MANUAL statement at 6.4.16

When the peripheral clock is not active, the peripheral registers read or write access is not

supported.

Am I making sense?

shingadaddy
Senior
Posted on March 16, 2016 at 17:03

Just for grins - here's what's in there at this time

Contents of sm32l4xx_it.c

/******************************************************************************/

/* STM32L4xx Peripherals Interrupt Handlers */

/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */

/* available peripheral interrupt handler's name please refer to the startup */

/* file (startup_stm32l4xx.s). */

/******************************************************************************/

/**

* @brief This function handles UART interrupt request.

* @param None

* @retval None

* @Note This function is redefined in ''main.h'' and related to DMA

* used for USART data transmission

*/

void USARTx_IRQHandler(void)

{

  HAL_UART_IRQHandler(&Uart_1_Handle); // RAP confirmed running after button push. Sends 3 bytes

}

void USART3_IRQHandler(void)

{

  HAL_UART_IRQHandler(&Uart_3_Handle);

}

shingadaddy
Senior
Posted on March 16, 2016 at 17:33

In my feable mind, AHB1 *HAS* to be working or USART 1 wouldn't work.(Correct?)

I have to kick on APB1 to get USART3 ( and a bunch of other peripherals on the right

of page 15 in DocID025976 rev 4) to work. (Correct?)

Thats supposedly done by this:

/******************************* SECOND UART -- UART 3 -- ***************************/

  if(huart->Instance == USART3)

  {

   USART3_RX_GPIO_CLK_ENABLE();

   USART3_TX_GPIO_CLK_ENABLE();

   USART3_CLK_ENABLE();   <------ !!!!!!!!!!

  

Which is defined in main.h as THIS:

#define USART3_CLK_ENABLE()              __HAL_RCC_USART3_CLK_ENABLE()

Which is a defined macro in stm32l4xx_hal_rcc.h as so:

#define __HAL_RCC_USART3_CLK_ENABLE()          do { \

                                                 __IO uint32_t tmpreg; \

                                                 SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN); \

                                                 /* Delay after an RCC peripheral clock enabling */ \

                                                 tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN); \

                                                 UNUSED(tmpreg); \

                                               } while(0)

                                              

Honestly - I'm STUCK... Which usually means I missed something simple.

shingadaddy
Senior
Posted on March 16, 2016 at 20:07

I figure someone might ask. (Hopefully SOON..) So here....Just so you know I HAVENT messed with it.. 🙂

/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2

clocks dividers */

RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;         <---------------------!!!!!!

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)

{

/* Initialization Error */

  while(1);

}

USART 1 working fine. I push the button on board #1( thats the transmit first, and then receive board)

and it TX's the buffer via IrDA to Board #2 (That would be the Receive then transmit board). Board 2

then Tx's that, via IrDA BACK to board 1. The boards both compare the TX and RX buffers (Well after

I fixed the ST bug in the compare routine) and then I tell USART3 to toggle TE.

Yes --- before it enters an infinate while loop at the bottom.

Pin 24 REMAINS HIGH all that time.

Help!... Please!

Posted on March 16, 2016 at 20:55

I really don't want to wade into the HAL and L4 stuff...

Use a debugger, and make sure the code you think is executing, actually is, and check with a peripheral register view.

Pin 24, connecting directly to that, or from the header? Are there any solder bridges in that path? If you send a stream of 'U' characters, can you see that on a scope?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
shingadaddy
Senior
Posted on March 16, 2016 at 21:25

Thank you clive1. I was apprehensive about HAL too. I used this example program as my starting point knowing I might not like the HAL aspects AND I am trying TrueSTUDIO. (No Truestudio low level examples.)

But I HAVE dug through it. Unless I missed something (and that is VERY possible) I *think* I can see how the code is working..Well -- Obviously not enough to tell what the heck is happening to my USART 3 however. I just can't find anything WRONG about what I am doing. I checked the signal AT THE HEADER. (CN10 pin 34) But as I said I see the level AT THE HEADER change under two conditions.

1 --- If I configure the GPIO/UART it is HIGH. If I DONT it stays LOW. And 

2 --- If I configure the GPIO/UART it is HIGH and it flops low during reset. Then back HI.

I do have some uber tiny leads that I can get on the pin of the component though. I can do that.

I'm using TrueSTUDIO and ST-LINK V2. Tools I am in no way very familiar with, other than coding and compiling.

A debugger will be new territory for me. My debugger for years has been an LED, switch and a scope.... ;-\

And register poking has been good to me. Understanding it at that level really helps me see a view thats as

close to the processor view as I can imagine.

I guess I could dig up some Low Level Uart stuff out of the ST offerings but there ARE NONE for Truestudio in the CubeL4 offering.

I know its a pain but I'll mark this as a HELPFUL POST if you would help me out on my path here?

I won't be upset if Mayla helps either... (HINT--HINT)

If you have debugger instructions, I'm all ears....er uh EYES..

shingadaddy
Senior
Posted on March 16, 2016 at 21:36

Hold the phone. I have something to try...

shingadaddy
Senior
Posted on March 16, 2016 at 21:52

Oh that's embarrassing....

You know I have that USART 1 set up to use the ENDEC. So USART 1 TX pin is technically driven different than USART3's TX pin.

And everywhere I have read about the USARTS in these STM uC's say that they send an IDLE frame any time TE is ENABLED. I took that literally and though that by disabling TE and re-enabling TE, I should see a level change on the TX out. In REALITY the document states (I BELIEVE) that, what will come out of the TX pin if TE is disabled it the level it is at in the GPIO config. (Now I need to verify THAT and why it is a 1 for me here)

I put my ENDEC ENABLING lines of code(4) onto the USART 3 setup.

NOW I get a toggle.

@@

  >

   -

I bet if I remove my ENDEC lines of code from USART 1  - I WONT get a toggling TX pin on it either.

Your suggestion of '' a stream of ''U'' characters made me think about this.

OH --- Its AF and Pulled up

See you answered every question I had!   Good work!

I'll go away for a while now...  I'll be back I'm sure.

Thanks clive1!