2

I’ve got a MCF5282 that I’m trying to use PDD4 as a GPIO on. In my setup code, I’ve got:

MCF5282_GPIO_DDRDD = 0x10;    /* cs on dd4. */
MCF5282_GPIO_PORTDD = 0x10; /* active-low. */

And in my main loop, I’ve got:

for( mainloop_cnt = 0; true; mainloop_cnt++ )
{
    MCF5282_GPIO_PORTDD = (mainloop_cnt & 0x10);
    /* other stuff. */
}

Which should give me a nice square wave on the oscilloscope, but the port doesn’t seem to be doing as I say. Am I missing some setup steps? I can’t find anything in the 5282 manual about a “Port DD pin-assignment register” to repurpose it from its “primary” role as DDATA.

Sam Skuce
  • 123
  • 5
  • Not everyone on the site celebrates Christmas, but there are significantly fewer people around right now. It may take a bit for you to get your answer, sorry for the delay. – Kortuk Dec 25 '10 at 16:46
  • @Kortuk, I expect that, but still better to get the question out there now so it's around when people get back. I'll poke it with a meaningless edit if nobody's answered by Monday. – Sam Skuce Dec 25 '10 at 17:41
  • Just making sure you knew why people were not jumping on your question. – Kortuk Dec 25 '10 at 17:51
  • Does `mainloop_cnt` toggle? Can you post complete code that shows this behaviour? – tyblu Dec 26 '10 at 09:45
  • @tyblu, mainloop_cnt increments each time through the loop. I've added the for-loop used as well. – Sam Skuce Dec 27 '10 at 00:59

2 Answers2

2

The datasheet makes it sound like you need to disconnect the on-chip debugger from port DD before you can use it as a normal port.

26.4 Functional Description

26.4.1 Overview

[...]

In single-chip mode, all pins are configured as digital I/O by default, except for debug data pins (DDATA[3:0]) and processor status pins (PST[3:0]). These pins are configured for their primary functions by default in all modes.

MCF5282 and MCF5216 ColdFire Microcontroller User’s Manual, Rev. 3, § 26, p. 27

In most MCUs I've used, alternate functions usually override GPIOs, which has the lowest priority.

Nick T
  • 12,360
  • 2
  • 44
  • 71
  • We never figured this out (we ended up using another pin for the GPIO), but your explanation is the only one I've heard that makes sense. – Sam Skuce Mar 01 '11 at 22:27
1

is mainloop_cnt correctly declared as an unsigned char? (can't comment anywhere yet, sorry)

Isaac
  • 296
  • 1
  • 3
  • It currently looks like MCF5282_GPIO_PORTDD should be toggling between 0x10 and 0x00, every sixteen iterations. You're not getting any output? – Isaac Dec 27 '10 at 01:09