Thursday 19 March 2015

HCS08 Example1-digital Read and write

//Frescale HCS08  MC9S08DZ128
//Codewarrior Development studio v 10.6
//Digital read and write//bitwise
//12/3/2015
//written by Binu Kannur
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
int sw;
void main(void)
{
 // EnableInterrupts;
  /* include your code here */
  PTBDD_PTBDD0=1;//set PortB data direction bit0  //output//PTxDD_PTxDDn
  PTBDD_PTBDD2=1;//set PortB data direction bit2 //output //PTxDD_PTxDDn
  PTDDD_PTDDD1=0;//set PortD data direction bit1 //Input  //PTxDD_PTxDDn

  for(;;)
  {
    __RESET_WATCHDOG();    /* feeds the dog */
   
     if( PTDD_PTDD1==1)// check PortD bit1 is high?//connect aswitch
    {
        PTBD_PTBD0=1;   //PortB bit0 high
        PTBD_PTBD2=0;   //PortB bit2 low
    }
    else if( PTDD_PTDD1==0)
    {
         PTBD_PTBD0=0;
        PTBD_PTBD2=1;
    }
   }
}
///////////////////////////////////////
//PTADD=0;     Port A all input
//PTxPEn   ---Pullup enable
//0—disable
//1- enable
//PTxSEn=1   slew rate enabled
//PTxSEn=0    slew rate disabled
//PTxDSn----low drive

//PTxDSn=1---high

CodeWarrior Development Studios|Freescale--Beginers Tutorial

CodeWarrior Development Studio installation Procedure for Freescale

For  CodeWarrior Development Studio installation go to the link  http://www.freescale.com/zh-Hans/ and Software&Tools > CodewarriorDevelopment Tool > Download

After Installtion open the IDE and follow the steps

Step1:
  Open File and start a bareboard project
The screen shoot is given below

Step2:
    Give Project Name


Step3:
          Select Your controller
           Here Iam using HCS08 family controller, MC9S08DZ128
Step4:
        Next Use the JTAG for programming



Step5:
       Next select Languages

Step6:
        You can select rapid application help. Here not used


Step7:
      Next select option and finish

Step8
       start programming