Hi guys,
( SORRY IF I DOUBLE POST , I AM NEW AND I MISTAKE FORUM )
I hope someone more capable of me can help me solve this dilemma.
I'm not a professional programmer so I apologize if my question could be trivial.
I am using Teensy 3.2 , great device by the way ....
I do not want to use function void attachInterrupt(uint8_t pin, void (*function)(void), int mode) because i must understand how it work to first , because i would like to manipulate Register directly .
In my example I want to enable one pins on the PORT C for input ,
and the unique interrupt 89 is enable by NVIC_ENABLE_IRQ(IRQ_PORTC); ,
, and the pin is configured for INT enable .
When INTERRUPT event happen ---> from kinesis.h this function will be called extern void portc_isr(void);
///////////////////////////////////////////////
uint32_t x=0;
void MY_FUNC(){
x++;
}
SIM_SCGC5 = ( 1 << 11 ) ; // EnablePortC Clock Gating Control Register 5 (SIM_SCGC5)
PORTC_PCR6 = ( 1 << 19 ) | ( 1 << 17 ) | ( 1 << 8 ) | ( 1 << 1 ) | ( 1 << 0 );
// where PRC6 is pin 11 of the register PORTC_PCR6
NVIC_SET_PRIORITY(IRQ_PORTC, 64); // set the priority to value 64
NVIC_ENABLE_IRQ(IRQ_PORTC); // enable IRQ for PORT C
//////////////////////////////////////////////////////////////////////////////
Now my point is ..... With this configuration, the whole port C is enabled for the interrupt 89 , but how can I address that pin PRC6 only to my MY_FUNC function?
How can I record the call of my function ?
I imagine using function pointers.
But what is the particular Interrupt memory register for that pin ?
Trying to understand the functioning mechanics of the function void attachInterrup() :
These lines in particular are those that carry out the addressing operation.
voidFuncPtr* isr_table = getIsrTable(config); // ??? i don't know , but i believe interr IRQ_PORTC
if(!isr_table) return;
uint32_t pin_index = getPinIndex(config); // i get the pin number
__disable_irq();
cfg = *config;
cfg &= ~0x000F0000; // disable any previous interrupt
*config = cfg;
isr_table[pin_index] = function; // set the function pointer !!!!!! THIS IS THE MOST !!!!
PLEASE can I have an example using the registers in a direct way ??
IM becoming crazy
NEED HELP
Thanks
Massi
( SORRY IF I DOUBLE POST , I AM NEW AND I MISTAKE FORUM )
I hope someone more capable of me can help me solve this dilemma.
I'm not a professional programmer so I apologize if my question could be trivial.
I am using Teensy 3.2 , great device by the way ....
I do not want to use function void attachInterrupt(uint8_t pin, void (*function)(void), int mode) because i must understand how it work to first , because i would like to manipulate Register directly .
In my example I want to enable one pins on the PORT C for input ,
and the unique interrupt 89 is enable by NVIC_ENABLE_IRQ(IRQ_PORTC); ,
, and the pin is configured for INT enable .
When INTERRUPT event happen ---> from kinesis.h this function will be called extern void portc_isr(void);
///////////////////////////////////////////////
uint32_t x=0;
void MY_FUNC(){
x++;
}
SIM_SCGC5 = ( 1 << 11 ) ; // EnablePortC Clock Gating Control Register 5 (SIM_SCGC5)
PORTC_PCR6 = ( 1 << 19 ) | ( 1 << 17 ) | ( 1 << 8 ) | ( 1 << 1 ) | ( 1 << 0 );
// where PRC6 is pin 11 of the register PORTC_PCR6
NVIC_SET_PRIORITY(IRQ_PORTC, 64); // set the priority to value 64
NVIC_ENABLE_IRQ(IRQ_PORTC); // enable IRQ for PORT C
//////////////////////////////////////////////////////////////////////////////
Now my point is ..... With this configuration, the whole port C is enabled for the interrupt 89 , but how can I address that pin PRC6 only to my MY_FUNC function?
How can I record the call of my function ?
I imagine using function pointers.
But what is the particular Interrupt memory register for that pin ?
Trying to understand the functioning mechanics of the function void attachInterrup() :
These lines in particular are those that carry out the addressing operation.
voidFuncPtr* isr_table = getIsrTable(config); // ??? i don't know , but i believe interr IRQ_PORTC
if(!isr_table) return;
uint32_t pin_index = getPinIndex(config); // i get the pin number
__disable_irq();
cfg = *config;
cfg &= ~0x000F0000; // disable any previous interrupt
*config = cfg;
isr_table[pin_index] = function; // set the function pointer !!!!!! THIS IS THE MOST !!!!
PLEASE can I have an example using the registers in a direct way ??
IM becoming crazy
NEED HELP
Thanks
Massi