ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Понедельник
25 ноября
242992
oblom_0ff (13.03.2011 02:56, просмотров: 1470)
Господа, помогите с CrossWorks... :(Задача такая: под CW 2.0 нужно создать таймер с частотой 10kHzпроц STM32F103RET6вот код, который упорно не хочет работать :( : void timer3Init(void) { NVIC_InitTypeDef NVIC_InitStructure;  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_OCInitTypeDef TIM_OCInitStructure; /* Enable the TIMER_TIM global Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); /* Time base configuration */ /* 72Mhz bus / 72 prescaler = 1MHz (us) */ TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); TIM_TimeBaseStructure.TIM_Period = 100-1; // 0xFFFF; // 0.1ms - 10000Hz TIM_TimeBaseStructure.TIM_Prescaler = 72 - 1; //72*910 - 1; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); ctl_events_init(&tim4Event, 0); memset(tim3Stack, 0xcd, sizeof(tim3Stack)); // write known values into the stack tim3Stack[0]=tim3Stack[1+STACKSIZE]=0xfacefeed; // put marker values at the words before/after the stack ctl_task_run(&tim4Task, 180, tim3Code, 0, "tim3Task", STACKSIZE, tim3Stack+1, 0); // Clear update pending flag TIM_ClearFlag(TIM3, TIM_FLAG_Update); // reset TIM_SetCounter(TIM3, 0); // go... TIM_Cmd(TIM3, ENABLE);}void tim3Code(void *p) { //noticeSend("Tim4 task started...\n"); while (1) {ctl_events_wait(CTL_EVENT_WAIT_ANY_EVENTS, &tim3Event, (1