cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 and usart

edouard
Associate II
Posted on August 09, 2015 at 23:03

Hello,

Im want to send data with USART2 (im using KEIL uVision 5).

Im trying to use this program :

/* USART2 PA.2 Tx, PA.3 Rx STM32F0-Discovery sourcer32@gmail.com */

 

#include ''stm32f0xx.h''

#include ''stm32f0_discovery.h''

 

int main(void)

{

  USART_InitTypeDef USART_InitStructure;

  GPIO_InitTypeDef GPIO_InitStructure;

 

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

 

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);

 

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1);

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_1);

 

  /* Configure USART2 pins:  Rx and Tx ----------------------------*/

  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_2 | GPIO_Pin_3;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

 

  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_No;

  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  USART_Init(USART2, &USART_InitStructure);

 

  USART_Cmd(USART2,ENABLE);

 

  while(1)

  {

   while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET)

 

   USART_SendData(USART2, 'X');

  }

}

Im using Keil in simulation mode, and when i want to debug it, i add the USART2 register to check it and it says : <cannot evaluate>, when i run the program, it says : *** error 65: access violation at 0x00000000 : no 'execute/read' permission

Basically, I would like to check the USART2 register to see if I do have X in this register. Thanks for your help

2 REPLIES 2
Posted on August 10, 2015 at 00:11

Ok, well this basically means that the simulation doesn't support the features of your part at the level you want to use them. Use the debugger on real hardware.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
RomainR.
ST Employee
Posted on August 11, 2015 at 14:01

correct Clive1

See

http://www.keil.com/dd/chip/6188.htm

Simulated Features

NOTE

Simulation for this device is provided by the default peripheral simulation driver.

Complete peripheral simulation is not available and is not planned to be implemented by ARM.

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.