Thursday, January 12, 2006

Freescale HCS908

The onboard demos work as described in the "Getting Started with the M68DEMO908GB60 rev 02)", but the file M68DEMO908GB60demo.mcp does not exist, there is not a "M68DEMS.zip" file included on the demo board CD. UPDATE: M68DEMS.zip is included on the CD underneath the Code Warrior package. But, even still, the code did not contain what was referenced.

Referencing the AN2616_Getting_Started_With_HCS08_and_CodeWarrior references (p4)AN2616SW.zip, which also does not exist with the bundled software. Sheesh.

So the HCS908 is debuggable, out of box, using the db9 serial connector with SCI1.

New project creation:
By selecting "P&E Full Chip Simulation", "P&E Hardware Debugging" and "Motorola Serial Monitor", it will be possible to use either simulation, the serial monitor within the HCS08 FLASH, or BDM to debug code.There is no code overhead as a result of choosing multiple connection methods.

To enable serial monitor connection press switch 4 and switch the power on, set the target to be "Monitor". Once the debugger appears a couple modal dialogs should quickly appear and disappear showing that the FLASH is being erased. If this doesn't happen then there is likely a communications problem and the simulator will then run the program.

Here's the first go at LED manipulation:

#include <hidef.h> /* for EnableInterrupts macro */
#include <MC9S08GB60.h> /* include peripheral declarations */

#define ON 0
#define OFF 1

#define UP 1
#define DOWN 0

#define LED1 PTFD_PTFD0
#define LED2 PTFD_PTFD1
#define LED3 PTFD_PTFD2
#define LED4 PTFD_PTFD3
#define LED5 PTFD_PTFD4

#define SWITCH1 PTAD_PTAD4
#define SWITCH2 PTAD_PTAD5
#define SWITCH3 PTAD_PTAD6
#define SWITCH4 PTAD_PTAD7
long approxTwoSeconds = 100000;


void delay(long millis){
long cnt=0;
for(cnt=0; cnt<millis; cnt++){
//wait
}
}
static void pulse(long flashTime){
LED1 = ON;
LED2 = ON;
LED3 = ON;
LED4 = ON;
LED5 = ON;
delay(flashTime);
LED1 = OFF;
LED2 = OFF;
LED3 = OFF;
LED4 = OFF;
LED5 = OFF;
delay(flashTime);
LED1 = ON;
LED2 = ON;
LED3 = ON;
LED4 = ON;
LED5 = ON;
delay(flashTime);
LED1 = OFF;
LED2 = OFF;
LED3 = OFF;
LED4 = OFF;
LED5 = OFF;
delay(flashTime);


}

static void simpleSequence(long delayBetweenLights){

LED1 = ON;
delay(delayBetweenLights);
LED1 = OFF;

LED2 = ON;
delay(delayBetweenLights);
LED2 = OFF;

LED3 = ON;
delay(delayBetweenLights);
LED3 = OFF;

LED4 = ON;
delay(delayBetweenLights);
LED4 = OFF;

LED5 = ON;
delay(delayBetweenLights);
LED5 = OFF;



}
void main(void) {
int cnt = 0;

EnableInterrupts; /* enable interrupts */
/* include your code here */
PTADD = 0;//initialize input
PTAPE=0xF0;//Pullups on upper 4 bits
PTFDD=0x0F; //initializes ports 0,1,2,3 of Port F as outputs (which are connected to the LEDs)
LED1=OFF;
LED2=OFF;
LED3=OFF;
LED4=OFF;
LED5=OFF;

for(;;) {

__RESET_WATCHDOG(); /* feeds the dog */

simpleSequence(approxTwoSeconds);
pulse(10000);
}

}

No comments: