9S08QG - Can't get ports to configure properly

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

9S08QG - Can't get ports to configure properly

1,589 Views
dandy
Contributor I
Hello group,

I'm just getting started with CW and am trying to setup the port I/O on a 9S08QG4. I must be missing something really silly because the ports are not changing from their input defaults. Here's what I'm doing in the code:

#include <hidef.h>
#include <MC9S08QG8.h>

<snip>

PTAD_PTAD0 = 0;           //set PTA0 LO
PTADD_PTADD0 = 1;    //set PTA0 as an output
PTADS_PTADS0 = 1;   //set PTA0 to High Drive Strength

This should set PTA0 as an output with a logic '0'.

What am I missing?

Thanks in advance.
dandy

Labels (1)
0 Kudos
3 Replies

313 Views
bigmac
Specialist III
Hello dandy,
 
Are you actually reaching the code where the port pin is set up?  What code precedes the snippet shown?  Is there any possibility that COP reset could be occurring?
 
Regards,
Mac
 
0 Kudos

313 Views
dandy
Contributor I
Hi Mac,

The COP was not disabled, however doing so does not seem to help. A bit more on my setup; I'm able to connect (P&E Multilink), download, and single step. I'm expecting the PTA pins which are being setup as outputs to change state as I step through the code. Nothing happens as I pass through those statements. I'm also able to change the PTA registers when I use the 'R' (show register) debug command and see the pins change state. One thing that also concerns me is that when I let the code run, I'm getting updates that indicate that the clock freq is changing (Frequency change to ~50526208hz, ..., etc).


Here's the entire code:

#include <hidef.h>
#include <MC9S08QG8.h>


void main(void) {


SOPT1_COPE = 0;     //disable COP
 
//WC4 Sensor TestinG

PTAD_PTAD0 = 1;     //set PTA0 HI
PTADD_PTADD0 = 1;   //set PTA0 as an output
PTADS_PTADS0 = 1;   //set PTA0 to High Drive Strength

PTAD_PTAD1 = 1;     //set PTA1 HI
PTADD_PTADD1 = 1;   //set PTA1 as an output
PTADS_PTADS1 = 1;   //set PTA1 to High Drive Strength

PTAD_PTAD2 = 1;     //set PTA2 HI
PTADD_PTADD2 = 1;   //set PTA2 as an output
PTADS_PTADS2 = 1;   //set PTA2 to High Drive Strength

PTAD_PTAD3 = 1;     //set PTA3 HI
PTADD_PTADD3 = 1;   //set PTA3 as an output
PTADS_PTADS3 = 1;   //set PTA3 to High Drive Strength
 
 
  for(;:smileywink: {

    PTAD_PTAD2 =~ PTAD_PTAD2;   //complement PTA2 output
}
  }

Thanks,
dandy

0 Kudos

313 Views
dandy
Contributor I
I managed to things working using the Quick Start GPIO Example project. I used the exact code (see prev post). I took a look at the two projects (start08, libs, etc) - both appear to be the same. Still not sure why it works and my original project doesn't.

dandy
0 Kudos