AnsweredAssumed Answered

GPIO behaviour registers in mc9s12xs128

Question asked by carles lloret on Jan 9, 2019

Hello, I have a question regarding codewarrior.

I have an inherited code, and I am wondering one thing. Is it possible to define registers like RDR, PER, PPS, PIE, PIF (registers to describe a pin... input, output, pull up, pull down) with a code? or is it necessary to use the Processor Expert?

Let's say I want to change the pull up-down register?  is it possible to do it by typing some code like...

 

/*--------- Port H --------------*/
#define PORT_H_DDR BIN2BYTE(11111111) /* Data direction 0=Input / 1=Output */
// ||||||||
// |||||||+------ bit0: NOT USED
// ||||||+------- bit1: NOT USED
// |||||+-------- bit2: NOT USED
// ||||+--------- bit3: NOT USED
// |||+---------- bit4: NOT USED
// ||+----------- bit5: NOT USED
// |+------------ bit6: NOT USED
// +------------- bit7: NOT USED
// 7-0
//DDRH
//Port H data direction—
//This bit determines whether the associated pin is an input or output.
//1 Associated pin configured as output
//0 Associated pin configured as input




#define PORT_H_RDR BIN2BYTE(00000000) /* 0x00 Reduced Drive: 0=full 1=1/3 */
//7-0
//RDRH
//Port H reduced drive—Select reduced drive for output pin
//This bit configures the drive strength of the associated output pin as either full or reduced. If a pin is used as input
//this bit has no effect. The reduced drive function is independent of which function is being used on a particular pin.
//1 Reduced drive selected (approx. 1/5 of the full drive strength)
//0 Full drive strength enabled





#define PORT_H_PER BIN2BYTE(00010000) /* Pull Devide: 0=pullup or down disable / 1=pullup or down enable */
// ||||||||
// |||||||+------ bit0: NOT USED
// ||||||+------- bit1: NOT USED
// |||||+-------- bit2: NOT USED
// ||||+--------- bit3: NOT USED
// |||+---------- bit4: NOT USED // BMS_IGN
// ||+----------- bit5: NOT USED
// |+------------ bit6: NOT USED
// +------------- bit7: NOT USED
//7-0
//PERH
//Port H pull device enable—Enable pull device on input pin
//This bit controls whether a pull device on the associated port input pin is active. If a pin is used as output this bit has
//no effect. The polarity is selected by the related polarity select register bit.
//1 Pull device enabled
//0 Pull device disabled



#define PORT_H_PPS BIN2BYTE(00000000) /* Polarity 0=fallin edge sets the flag (pull-up) / 1=Rising edge sets the flag (pull-Down)*/
// ||||||||
// |||||||+------ bit0: NOT USED
// ||||||+------- bit1: NOT USED
// |||||+-------- bit2: NOT USED
// ||||+--------- bit3: NOT USED
// |||+---------- bit4: NOT USED //BMS_IGN
// ||+----------- bit5: NOT USED
// |+------------ bit6: NOT USED
// +------------- bit7: NOT USED
//7-0
//PPSH
//Port H pull device select—Configure pull device and pin interrupt edge polarity on input pin
//This bit selects a pull-up or a pull-down device if enabled on the associated port input pin.
//This bit also selects the polarity of the active pin interrupt edge.
//1 A pull-down device selected; rising edge selected
//0 A pull-up device selected; falling edge selected


#define PORT_H_PIE BIN2BYTE(00000000) /* Interrupt Enable 0=disable 1=Enable */
//7-0
//PIEH
//Port H interrupt enable—
//This bit enables or disables on the edge sensitive pin interrupt on the associated pin.
//1 Interrupt enabled
//0 Interrupt disabled (interrupt flag masked)



#define PORT_H_PIF_MASK BIN2BYTE(00000000) /* Interrupt flag, write 1 clear the flag */

 

 

 

This, for example, PORT_H_PIE is a register that enables or not the interruptions in the port h. By typing and defining as such "PORT_H_PIE BIN2BYTE(00000000) ", is it enough to define or change the behaviour of the GPIO in the PORT H? Is even PORT_H_PIE a key word?

 

 

In another code I can read...

 

volatile PTHSTR _PTH; /* Port H Data Register; 0x00000260 */
volatile PTIHSTR _PTIH; /* Port H Input Register; 0x00000261 */
volatile DDRHSTR _DDRH; /* Port H Data Direction Register; 0x00000262 */
volatile RDRHSTR _RDRH; /* Port H Reduced Drive Register; 0x00000263 */
volatile PERHSTR _PERH; /* Port H Pull Device Enable Register; 0x00000264 */
volatile PPSHSTR _PPSH; /* Port H Polarity Select Register; 0x00000265 */
volatile PIEHSTR _PIEH; /* Port H Interrupt Enable Register; 0x00000266 */
volatile PIFHSTR _PIFH; /* Port H Interrupt Flag Register; 0x00000267 */

 

However, I cannot find a relation between _DDRH and PORT_H_DDR...

 

 

Thank you all.

Attachments

Outcomes