使用STM32F103VC在MDK下仿真,能够得到正确的结果,MCU改成STM32F107VC之后,编译时没有问题,但是仿真的时候,提示“*** error 65: access violation at 0x40021000 : no 'read' permission”,
1、 初始化代码如下
void MyUsartInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA, ENABLE); //????USART1??GPIOA?±??
USART_DeInit(USART1); //????????1
//USART1_TX   A.9
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //PA.9
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //???????ì????
GPIO_Init(GPIOA, &GPIO_InitStructure); //??????PA9
//USART1_RX   A.10
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//????????
GPIO_Init(GPIOA, &GPIO_InitStructure); //??????PA10
//USART ???????è??
USART_InitStructure.USART_BaudRate = 9600;//??°??è????9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//×??¤??8??????????
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(USART1, &USART_InitStructure); //??????????
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//????????
USART_Cmd(USART1, ENABLE); //????????
}
2、相关设置如下
3、主函数如图所示:
4、编译无错误:
5、点击仿真后,提示
“*** error 65: access violation at 0x40021000 : no 'read' permission”,
6、直接下载到开发板运行,串口无输出,附件为工程文件,麻烦有板子的帮忙试试,谢谢!!
请问下如何解决啊,谢谢!!
|