Вопрос

I'm trying to learn C to program this small routine on a Texas Instruments MSP430. Could you help me understand the ((unsigned char *) 0x0023) part?

I'm having issues understanding this middle portion of this Define directive. I've tried looking this up but found nothing on the ((unsigned char *) 0x0023) portion. This looks like a type cast but its not casting anything.

My major concern is the 0x0023 (decimal 35). Is this just a unsigned char pointer with 35 bits?

Code:

#define P1IFG_ptr ((unsigned char *) 0x0023) unsigned char result;

Any help is really appreciated and thank you in advance.

Это было полезно?

Решение

((unsigned char *) 0x0023)

Is a pointer to address 0x23

I think there's a missing newline in your code sample...

On the MSP430 this is the port P1 interrupt flag register:

Each PxIFGx bit is the interrupt flag for its corresponding I/O pin and is set when the selected input signal edge occurs at the pin. All PxIFGx interrupt flags request an interrupt when their corresponding PxIE bit and the GIE bit are set. Each PxIFG flag must be reset with software. Software can also set each PxIFG flag, providing a way to generate a software initiated interrupt. Bit = 0: No interrupt is pending Bit = 1: An interrupt is pending Only transitions, not static levels, cause interrupts. If any PxIFGx flag becomes set during a Px interrupt service routine, or is set after the RETI instruction of a Px interrupt service routine is executed, the set PxIFGx flag generates another interrupt. This ensures that each transition is acknowledged.

You can read from this register, e.g.:

unsigned char result;
result = *P1IFG_ptr;

Or write to it, e.g.:

*P1IFG_ptr = 1;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top