cancel
Showing results for 
Search instead for 
Did you mean: 

STR9 problem with VIC

rastaxe
Associate II
Posted on November 28, 2007 at 03:35

STR9 problem with VIC

2 REPLIES 2
rastaxe
Associate II
Posted on May 17, 2011 at 11:31

I'm using 91x_lib and I'm trying to write a simple application that use TIM and VIC interrupts. I haven't any examples, someone have examples?

This is my code that doesn't work:

***** main.c ******

#include ''91x_lib.h''

TIM_InitTypeDef TIM_InitStructure;

GPIO_InitTypeDef GPIO_InitStructure;

void main(void)

{

#ifdef DEBUG

debug();

#endif

SCU_APBPeriphClockConfig(__VIC, ENABLE);

/* Deinitialize the VIC */

VIC_DeInit();

SCU_APBPeriphClockConfig(__GPIO6, ENABLE);

GPIO_DeInit(GPIO6);

SCU_APBPeriphClockConfig(__GPIO3, ENABLE);

GPIO_DeInit(GPIO3);

SCU_APBPeriphClockConfig(__TIM01, ENABLE);

TIM_DeInit(TIM0);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;

GPIO_Init(GPIO6,&GPIO_InitStructure);

/* GPIO4 configuration (PWM on P4.0 pin 3) */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2;

GPIO_Init(GPIO3,&GPIO_InitStructure);

/* TIM0 Structure Initialization */

TIM_StructInit(&TIM_InitStructure);

/* TIM0 Configuration in PWM Mode */

TIM_InitStructure.TIM_Mode = TIM_PWM;

TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB;

TIM_InitStructure.TIM_Prescaler = 0xFF;

TIM_InitStructure.TIM_Pulse_Level_1 = TIM_HIGH;

TIM_InitStructure.TIM_Period_Level = TIM_LOW;

TIM_InitStructure.TIM_Pulse_Length_1 = 0x3FF;

TIM_InitStructure.TIM_Full_Period = 0xFFF;

TIM_Init (TIM0, &TIM_InitStructure);

VIC_Config(TIM0_ITLine, VIC_IRQ, 0);

VIC_ITCmd(TIM0_ITLine,ENABLE);

TIM_ITConfig(TIM0,TIM_IT_IC1|TIM_IT_OC1|TIM_IT_TO|TIM_IT_IC2|TIM_IT_OC2,ENABLE);

/* Start the counter of TIM0 */

TIM_CounterCmd(TIM0, TIM_START);

while(1){

VIC_SWITCmd(TIM0_ITLine, ENABLE);

}

}

***** 91x_it.c ***

....

void TIM0_IRQHandler(void)

{

GPIO_WriteBit(GPIO6, GPIO_Pin_All, Bit_RESET );

}

....

i239955_stm1_st
Associate
Posted on May 17, 2011 at 11:31

Hi,

declare your IRQ function in it.c like this one, don't forget to change it.h :

__irq void TIM0_IRQHandler(void)

{

''Code''

// VIC re-init

TIM_ClearFlag(TIM2, TIM_FLAG_TO); //TimerFlag clear

VIC0->VAR = 0 ; //dummy for VIC0 Line

VIC1->VAR = 0 ; //dummy for VIC1 Line

}

in VIC.C you must change the function

static void VIC_ISRVectAddConfig(u16 VIC_Source, u16 VIC_Priority,

void (*VIC_VectAddress);

to:

static void VIC_ISRVectAddConfig(u16 VIC_Source, u16 VIC_Priority,

void (*VIC_VectAddress)(void)__irq);