MSP Port-Interrupt:int_pin_to_index

By jeik , 18 April 2013

I don't understand this routine


// File msp430_interrupt.c
static inline unsigned char int_pin_to_index(unsigned short pin)
{
/* Remove INT_PORT_Px from pin; index = pin/2 - 1. */
return ((pin & 0x1F) >> 1) - 1;
}

First, I have for example P2IN7 as port to fsync, and I get
index <= 0xff
what's gives memory overflow in the P2_INT-Routine.
Even for , for example Bit 0, it would yield 0xff???
Can you please explain this?

mlaverne

12 years 11 months ago

You are returning a char, so if the shift to the right with 1 bit results in 0 (so, if pin was set to 1 for instance), then 0 - 1 = -1 == 0xFF in unsigned char.

phpbb Post ID
22896

jeik

12 years 11 months ago

You are returning a char, so if the shift to the right with 1 bit results in 0 (so, if pin was set to 1 for instance), then 0 - 1 = -1 == 0xFF in unsigned char.

This is clear, but it is a library routine from INVENSENSE.
I would like a explanation of this routine in the context of the P2_INT.
regards
phpbb Post ID
22899

guy_mcilroy

12 years 11 months ago

It is a helper function used to help identify what pin of what register is set to fire off the input capture interrupt. It can be simplified by just hard-coding it for your platform.

phpbb Post ID
22902
phpbb Topic ID
15228