高中生
最后登录1970-1-1
在线时间 小时
注册时间2014-4-22
|
这是我写的调试程序,所有的程序都是野火的教程里的程序,但运行到LCD_Init();就死,
不知怎么回事,调试出现这些信息
**jtag Warning:CPU could not be halted
**jtag Warning:CPU could not be halted
不知有没有遇到相同问题的,求指导
int main(void){
int n =0;
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
//定义GPIOB,推挽输出
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIO_InitStructure);
//定义TIM2
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
TIM_TimeBaseStructure.TIM_Period = 500;//TIM->ARR 自动重装载寄存器
TIM_TimeBaseStructure.TIM_Prescaler = 71;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure);
TIM_ClearFlag(TIM2,TIM_FLAG_Update);//clear the flag TIMx->SR bit0(UIF)
TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);//
TIM_Cmd(TIM2,ENABLE);//TIMx->CR1 CEN=1;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 , DISABLE);//先关闭等待使用
//设置TIM2中断
NVIC_PriorityGroupConfi(NVIC_PriorityGroup_0);
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;//指定响应优先级
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
//设置串口UART1
//设置UART1_TX, RX io口
RCC_APB2PeriphClockCmd
(RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA,&GPIO_InitStructure);
//Rx pin input
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA,&GPIO_InitStructure);
//UART1 mode config
USART_InitStructure.USART_BaudRate = 115200;
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(USART1,&USART_InitStructure);
USART_Cmd(USART1, ENABLE);
/* TIM2 重新开时钟,开始计时 */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 , ENABLE);
LCD_Init();
LCD_Clear(0, 0, 240, 320, BACKGROUND);
LCD_DispChar(60, 60, 'A', RED);
LCD_DispStr(10, 10, (uint8_t *)"This is a lcd demo to display ascii", RED);
LCD_DispStr(40, 100, (uint8_t *)"count:", RED);
for( n=0; n<500000; n++ )
{
LCD_DisNum(100, 100, n, RED);
Lcd_Delay(0xAFFf>>4);
}
while(1){
if(cnt>=1000){
cnt = 0;
GPIOB->ODR ^= 1;
printf("hello world!\n");
}
}
}
|
|