Using Port A as a general purpose output - MC9S12C32 controller

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

Using Port A as a general purpose output - MC9S12C32 controller

4,138 次查看
KH_SRNL
Contributor I
This should be really simple, but I'm stuck.  I want to use a bit on Port A to drive a chip select line on a peripheral chip.  The problem is I don't appear to be toggling the Port A pin.  My test code snippet is very simple:
 
DDRA = 0xff;
while(1)
{
PTAD = 0x00;
delay(5000);
PTAD = 0xff;
delay(5000);
}
 
I verified the routine with Port T and it works fine.  I'm looking at the output of Port A with a meter and seeing no state change.  I'm assuming that Port A can drive the line high (without a pull-up resistor).  The chip is on an ElMicro CHIPS12 carrier board and I'm using the Imagecraft V6 compiler.  Any ideas on what's going on???


Message Edited by KH@SRNL on 2008-05-28 09:04 PM
标签 (1)
0 项奖励
回复
7 回复数

1,672 次查看
KH_SRNL
Contributor I
Thanks, but that's not quite it.  I caught my own mistake (eventually).
 
DDRAD is the correct port configuration register (I was using DDRA).  DDRAD sets the port pins as input or output.
 
PTAD is the general purpose digital input / output port
 
PORTA is the digital input only read register
0 项奖励
回复

1,672 次查看
kef
Specialist I


KH@SRNL wrote:
 
PORTA is the digital input only read register


No, PORTA is port A I/O R/W data register.
 
PTAD (I/O) and PORTAD (I-only) are port AD (ATD pins) data registers.
 
0 项奖励
回复

1,672 次查看
Lundin
Senior Contributor IV
On HCS12, ports A, B, E and K are called PORTA, PORTB etc. The rest of the ports are called PTT, PTM etc. Very inconsistent.

PORTA is indeed the I/O register.

PORTAD0 is the input-only register from the AD.

PTAD is the name for port A on a HCS08 device.
0 项奖励
回复

1,672 次查看
kef
Specialist I
We are talking about C32. And C32 has two AD port data registers, PTAD and PORTAD (according to C32 datasheet there's no PORTAD0 register). PTAD data register belongs to PIM module and read only PORTAD - to ATD module.
0 项奖励
回复

1,672 次查看
Lundin
Senior Contributor IV
You are correct. I checked the register names by looking at some code I wrote for a C32, but I had forgotten that the code was using the memory map for a DG128...
0 项奖励
回复

1,672 次查看
allawtterb
Contributor IV


KH@SRNL wrote:
PTAD is the general purpose digital input / output port
 
PORTA is the digital input only read register


I am not sure when you mean with Port A is a digital input only read register.  Port A can be used as a general purpose I/O but the chip used in your module is the 48 pin package which contains only Bit 0 of Port A.  Your module is using it as the SDA line to connect an I2C EEPROM.
0 项奖励
回复

1,672 次查看
kef
Specialist I

DDRA - Port A (PTA) data direction register

PTAD - Port AD (PTAD) data register

PORTA - Port A (PTA) data register

No wonder your code doesn't work.

0 项奖励
回复