STM32 串口通信不能进中断是为什么啊?

[复制链接]
查看11 | 回复2 | 2011-3-9 20:35:57 | 显示全部楼层 |阅读模式
是这样设置的:
void uart_initial(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //usart1 tx
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //usart1 rx
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);



GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);



GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //usart2 tx
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; //usart2 rx
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOD, &GPIO_InitStructure);


USART1->BRR = 72000000/4800;
USART1->CR1 = (u16)0x206c;
USART1->SR = 0;



USART2->BRR = 36000000/4800;
USART2->CR1 = (u16)0x206c;
USART2->SR = 0;


//5、中断配置:
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);


NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}

回复

使用道具 举报

千问 | 2011-3-9 20:35:57 | 显示全部楼层
0][32];,code啥意思?不用这个呢?直接unsigned char Cmp[10][32]? 外接flash,用单片机io口模拟flash操作时序,好麻烦啊,干脆买个好点的单片机得了,msp430 ,比较适合学生,要不,stm32
回复

使用道具 举报

千问 | 2011-3-9 20:35:57 | 显示全部楼层
这一句GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);USART2做嘛用的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行