Output Pin Manipulation for Coldfire 5212 (CodeWarrior)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Output Pin Manipulation for Coldfire 5212 (CodeWarrior)

1,548 次查看
JimMcP
Contributor I
I am trying to raise and lower signals on Port TA (General Purpose Timers/PWM).

Port TA (to be set for General Purpose I/O):

GPT3 (Pin 43) – DCD1 (Uart1 - Modem)
GPT2 (Pin 42) – DTR1 (Uart1 - Modem)
GPT1 (Pin 41) – DCD0 (Uart0 - Host)
GPT0 (Pin 40) – DTR0 (Uart0 - Host)

// Port TA Setup
// GPT3 and GPT0 as GPIO inputs (DCD Modem and DTR Host)
// GPT2 and GPT1 as GPIO outputs (DTR Modem and DCD Host)
MCF_GPIO_DDRTA = 0 | MCF_GPIO_DDRTA_DDRTA2 //DTR Modem
| MCF_GPIO_DDRTA_DDRTA1; //DCD Host
MCF_GPIO_PTAPAR=0;
//////////////


I want to raise or lower DTR1 and DCD0 pins.

Is this correct?
//Raise DTR1 pin
MCF_GPIO_PORTTA = MCF_GPIO_SETTA | MCF_GPIO_PORTTA_PORTTA2

//Raise DCD0 pin
MCF_GPIO_PORTTA = MCF_GPIO_SETTA | MCF_GPIO_PORTTA_PORTTA1

//Lower DTR1 pin
MCF_GPIO_PORTTA = MCF_GPIO_CLRTA | MCF_GPIO_PORTTA_PORTTA2

//Lower DCD0 pin
MCF_GPIO_PORTTA = MCF_GPIO_CLRTA | MCF_GPIO_PORTTA_PORTTA1

It does not seem to work. Is this the correct code format to raise and lower outputs on the Coldfire 5212. Is there any code examples to manipulate output pins?

Thanks,
标签 (1)
标记 (1)
0 项奖励
1 回复

375 次查看
Nouchi
Senior Contributor II
hello,


If you want to set one or several pin, you have to do this:
MCF_GPIO_PORTTA = portValue;
or using Port pin data/Set dataregister:
MCF_GPIO_SETTA = MCF_GPIO_PORTTA_PORTTA2; // port set register
// Cf doc chap 11.6.3
to clear use:
MCF_GPIO_CLRTA = ~MCF_GPIO_PORTTA_PORTTA2; // port clear register
// Cf doc chap 11.6.4
if you want to read the real pin state use:
uint8 yourVar;
yourVar = MCF_GPIO_SETTA; // chap 11.6.3

Don't forget to set the Data Direction Degister (chap 11.6.2)


Emmanuel
0 项奖励