cancel
Showing results for 
Search instead for 
Did you mean: 

USART2 problem....

yogee00
Associate II
Posted on May 02, 2013 at 19:20

i am trying to interface gsm module , I want to use USART2 and USART3 ...

but I am not getting how to do that can anyone suggest me ...

thank you ..

iam attaching the code i am using in the attachments .

#rs232-discovery-max3232-usart #tldr
7 REPLIES 7
Posted on May 02, 2013 at 19:35

Figure out what pins you plan on using. Determine if the external peripherals need to connect at CMOS Serial levels, or RS232 levels.

Insufficient data here.

STM32L USART3, try

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32L15x%20UART%20Configuration%20and%20use%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yogee00
Associate II
Posted on May 02, 2013 at 19:40

sorry , I think u ddnt see my attachment in this post ...

iam attaching my program file here ..

________________

Attachments :

yogesh.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzZg&d=%2Fa%2F0X0000000bNj%2FVxmca7uQTMvJvT.IeSCxWIpIcrCTDS.1vo9FZSOcAPY&asPdf=false
yogee00
Associate II
Posted on May 02, 2013 at 19:42

I think in this there is a problem ...

void RCC_Configuration(void)

 {

  RCC_HCLKConfig(RCC_SYSCLK_Div1);    // AHB Clock (HCLK) at 2.097 MHz

  RCC_PCLK1Config(RCC_HCLK_Div1);        // Low speed APB1 clock (PCLK1) clock at 2.097 MHz

  RCC_APBeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);                // ENABLE GPIO CLOCK

  //RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE);    // ENABLE USART3 CLOCK

  //RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); // ENABLE USART2 CLOCK

 // RCC_APB2PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);

 }// end of funciton RCC_Configuration()

Posted on May 02, 2013 at 19:48

If you're using PB10/11, then you'll need to enable the GPIOB clock also.

Enable APB1 clocks for USART2 and USART3

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 02, 2013 at 20:02

sorry , I think u ddnt see my attachment in this post ...iam attaching my program file here ..

Sorry, I saw, a lot to wade through. Doesn't really describe the connectivity, and failure. The STM32L-Discovery has no serial ports attached, need to be more explicit about how this is wired up, and to what (part#, pin designations, not generic description). Should have this separate from code, ie summary.

Try to evaluate USART function outside core application, then integrate.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yogee00
Associate II
Posted on May 02, 2013 at 20:10

I will write all description ..... :)

i am beginner so , I ddnt notice .

thank you for correcting .

:)

Posted on May 02, 2013 at 20:12

From other thread, blind mod for USART2

// sourcer32@gmail.com - STM32L15x USART2 Demo 9600 8N1
#include ''stm32l1xx.h''
void main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/* Assumes CMSIS and SystemInit() set up clocks before calling main() */
/* Enable GPIO A clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
/* Enable USART2 clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
/* Configure USART Rx & Tx as alternate function */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Mux out USART2 Rx & Tx */
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2); // PA2 USART2_TX
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2); // PA3 USART2_RX
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_None;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
/* USART configuration */
USART_Init(USART2, &USART_InitStructure);
/* Enable USART */
USART_Cmd(USART2, ENABLE);
while(1)
{
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); /* Waitwhile TX full */
USART_SendData(USART2, 0xAA);
}
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..