This is MPC5744P A[0] Configure. I wander if set like this:
MSCR[0].sss = 0001b
IMCR[48].sss = 0001b
IMCR[59].sss = 0010b
What will A[0] be? Is there priority between MSCR[0].sss & IMCR[x].sss ?
If I want to set IMCR[x].sss(for example like REQ0) , should I have to set MSCR[0].sss=0?
Thank you very much!
If I want use port A[0] as "etimer_0 input data channel 0", Which to choose?
A: MSCR[0].sss = 0001b
B: IMCR[59].sss = 0010b
C: both of A&B
D: ethier of A&B
Thank you!
1) MSCR[0].ibe = 1 to enable input buffer (sss field is not important when output functionality is disabled).
2) IMCR[59].sss = 0010b to route etimer_0 inpu_data_channel_0 to A[0] input buffer.
if i want to set A[0] to output pin.
A[0]MSCR[0]=0x0;
IMCR[xx]=xx?
how to set it?
Sorry, syntax highlight here is awful...
You can use these macros to help you:
/* GPIO & SIUL macros */
#define PortOffset(pn) (16 * pn)
#define Port(name,pin) ((Port##name) + pin)
#define SIUL_Out(pin,sss) { \
SIUL2.MSCR[Port pin].B.SSS = sss; /* Pin functionality */ \
SIUL2.MSCR[Port pin].B.src=3; /* Maximum slew rate */ \
SIUL2.MSCR[Port pin].B.OBE = 1; /* Output Buffer Enable on */ \
SIUL2.MSCR[Port pin].B.IBE = 0; /* Input Buffer Enable off */ \
}
#define SIUL_In(pin,imcr,sss) { \
SIUL2.IMCR[imcr - 512].B.SSS = sss; /* Pin functionality */ \
SIUL2.MSCR[Port pin].B.OBE = 0; /* Output Buffer Enable off */ \
SIUL2.MSCR[Port pin].B.IBE = 1; /* Input Buffer Enable on */ \
}
/* Set value of GPIO output */
#define GPIO_VO(pin) SIUL2.GPDO[Port pin].B.PDO_4n
/* Get value of GPIO input */
#define GPIO_VI(pin) SIUL2.GPDI[Port pin].B.PDI_4n
/* Setup GPIO as output */
#define GPIO_Out(pin,v) { \
SIUL2.GPDO[Port pin].B.PDO_4n = v; /* Set initial pin value */ \
SIUL_Out(pin,0); /* Pin functionality as GPIO*/ \
}
/* Setup GPIO as input */
#define GPIO_In(pin) { \
SIUL2.MSCR[Port pin].B.SSS = 0; /* Pin functionality as GPIO*/ \
SIUL2.MSCR[Port pin].B.OBE = 0; /* Output Buffer Enable off */ \
SIUL2.MSCR[Port pin].B.IBE = 1; /* Input Buffer Enable on */ \
}
/* Usage example */
#define LED1GIO (A,0)
#define LED1 GPIO_VO(LED1GIO)
void func(void){
/* GPIO as output, initialized as 0 */
GPIO_Out(LED1GIO, 0);
/* Set value of GPIO to 1 */
LED1 = 1;
}
#define SIUL_Out(pin,sss) { | \ | ||
SIUL2.MSCR[Port pin].B.SSS = sss; /* Pin functionality | */ \ | ||
SIUL2.MSCR[Port pin].B.src=3; | /* Maximum slew rate | */ \ | |
SIUL2.MSCR[Port pin].B.OBE = 1; | /* Output Buffer Enable on */ \ | ||
SIUL2.MSCR[Port pin].B.IBE = 0; | /* Input Buffer Enable off */ \ | ||
} |
/* Setup GPIO as output */
#define GPIO_Out(pin,v) { \
SIUL2.GPDO[Port pin].B.PDO_4n = v; /* Set initial pin value */ \
SIUL_Out(pin,0); /* Pin functionality as GPIO*/ \
}
IMCR register says how to route signal from particular input buffer to particular module (thus it is input configuration).
MSCR configures pad in general and selects its output configuration (SSS field says which particular module’s output signal is routed to the output buffer).
Thank you very much!