AnsweredAssumed Answered

Making a KBI Library...

Question asked by Ricard Comas on May 20, 2019
Latest reply on May 21, 2019 by Ricard Comas

Hello everyone and firstly, I woul like say to this communityt THANKS! because of your help, you always helps me! So

In my Jobs we are trying to make a library for use of KBI pheripherial. We know that there's a low level kbi component, and we got that It work successfully, However we want use KBI without add the component, I mean, using low level registers, We got do it! but not all, we have a initialize code (clear kbi flags, init clock for this, edge selection etc...) and we use the PE_ISR macro to specify our interrupt, but it doesn't work!, it works only when add the component and mark "Interrupt" option, just like the image below:

 

So KBI0 only work (with our code) and checking "Inerrupt resuest: Enabled", but in our code we enable the KBI interrupt in the KBI0_SC register, but doesn't work, we need add the component so that enable that interrupt, why?¿

 

This is our init code:

 

void initKBI(void){

/* Register 'KBI0_SC' initialization */
#if KBI0_SC_MASK_1
#if KBI0_SC_MASK_1 == 0xFFFFFFFF
KBI0_SC = KBI0_SC_VALUE_1;
#elif KBI0_SC_MASK_1 == KBI0_SC_VALUE_1
KBI0_SC |= KBI0_SC_VALUE_1;
#elif KBI0_SC_VALUE_1 == 0
KBI0_SC &= ~KBI0_SC_MASK_1;
#else
KBI0_SC = (KBI0_SC & (~KBI0_SC_MASK_1)) | KBI0_SC_VALUE_1;
#endif
#elif defined(KBI0_SC_VALUE_1)
KBI0_SC = KBI0_SC_VALUE_1;
#endif

/* Register 'KBI0_ES' initialization */
#ifdef KBI0_ES_VALUE
KBI0_ES = KBI0_ES_VALUE;
#endif

/* Register 'KBI0_PE' initialization */
#ifdef KBI0_PE_VALUE
KBI0_PE = KBI0_PE_VALUE;
#endif

/* Register 'KBI0_SC' initialization */
#if KBI0_SC_MASK_2
#if KBI0_SC_MASK_2 == 0xFFFFFFFF
KBI0_SC = KBI0_SC_VALUE_2;
#elif KBI0_SC_MASK_2 == KBI0_SC_VALUE_2
KBI0_SC |= KBI0_SC_VALUE_2;
#elif KBI0_SC_VALUE_2 == 0
KBI0_SC &= ~KBI0_SC_MASK_2;
#else
KBI0_SC = (KBI0_SC & (~KBI0_SC_MASK_2)) | KBI0_SC_VALUE_2;
#endif
#elif defined(KBI0_SC_VALUE_2)
KBI0_SC = KBI0_SC_VALUE_2;
#endif

/* Register 'KBI0_SC' initialization */
#if KBI0_SC_MASK_3
#if KBI0_SC_MASK_3 == 0xFFFFFFFF
KBI0_SC = KBI0_SC_VALUE_3;
#elif KBI0_SC_MASK_3 == KBI0_SC_VALUE_3
KBI0_SC |= KBI0_SC_VALUE_3;
#elif KBI0_SC_VALUE_3 == 0
KBI0_SC &= ~KBI0_SC_MASK_3;
#else
KBI0_SC = (KBI0_SC & (~KBI0_SC_MASK_3)) | KBI0_SC_VALUE_3;
#endif
#elif defined(KBI0_SC_VALUE_3)
KBI0_SC = KBI0_SC_VALUE_3;
#endif

 

}

 

and in the header filer:

 

void initKBI(void);

PE_ISR(interruptio);

 

 

and events.c

 

 


PE_ISR(interrupcio)
{

//Doing something...

KBI0_SC |= KBI_SC_KBACK_MASK; //Clear the flag

}

 

 

Have we do something else apart of initial code ?

Outcomes