Hello,
I just bought the freescale TOWER with coldfire v1 (MCF51CN) in the CPU board.
The problem i have is that no matter what port i use, i can only control the bit 1! It happened for PTA and for PTJ.
I think it may be any jumper configuration in the board, i’ve already looked for some mistake but i havent find anything wrong.
Is there somebody used with the tower kit who could help me?
In the header of the processor is the following code:
PTJD is data register and PTJDD is the direction register <
/*** PTJD - Port J Data Register; 0xFFFF8080 ***/
typedef union {
byte Byte;
struct {
byte PTJD0 :1; /* Port J Data Register Bit 0 */
byte PTJD1 :1; /* Port J Data Register Bit 1 */
byte PTJD2 :1; /* Port J Data Register Bit 2 */
byte PTJD3 :1; /* Port J Data Register Bit 3 */
byte PTJD4 :1; /* Port J Data Register Bit 4 */
byte PTJD5 :1; /* Port J Data Register Bit 5 */
byte :1;
byte :1;
} Bits;
struct {
byte grpPTJD :6;
byte :1;
byte :1;
} MergedBits;
} PTJDSTR;
extern volatile PTJDSTR _PTJD @0xFFFF8080;
#define PTJD _PTJD.Byte
#define PTJD_PTJD0 _PTJD.Bits.PTJD0
#define PTJD_PTJD1 _PTJD.Bits.PTJD1
#define PTJD_PTJD2 _PTJD.Bits.PTJD2
#define PTJD_PTJD3 _PTJD.Bits.PTJD3
#define PTJD_PTJD4 _PTJD.Bits.PTJD4
#define PTJD_PTJD5 _PTJD.Bits.PTJD5
#define PTJD_PTJD _PTJD.MergedBits.grpPTJD
#define PTJD_PTJD0_MASK 1
#define PTJD_PTJD1_MASK 2
#define PTJD_PTJD2_MASK 4
#define PTJD_PTJD3_MASK 8
#define PTJD_PTJD4_MASK 16
#define PTJD_PTJD5_MASK 32
#define PTJD_PTJD_MASK 63
#define PTJD_PTJD_BITNUM 0
My “init_IO” function code is this:
void GPIO_Init(void)
{
/* set Data Direction as OUTPUT */
PTJDD = 0xFF;
/* set switches as INPUT */
PTGDD &= ~0xC0;
PTGPE |= 0xC0;
/* set Data */
PTJD |= 0x0F;
}
And the loop which checks the switch status is this:
if (PTGD & 0x80)
{
PTJD |= 0x1F;
}
else
{
PTJD &= ~0x1F;
}