AnsweredAssumed Answered

BASIC SWITCH USAGE

Question asked by sheetanshkaushik on Dec 5, 2012
Latest reply on Dec 12, 2012 by sheetanshkaushik

Hi! I am new to microcontroller programming so please be patient. the following will seem like a stupid question.

I am using DEMO9S08AW60E and using Codewarrior(Version: 5.9) with PE.

-------------Code Begins.

PTFDD = 0x00;  // to activate/intialize the port F and D

PTDDD = 0x00;

 

if ((PTDD_PTDD2 |= 0x02))

{

      PTFD_PTFD0 |=0x01;

}

else

{

PTFD_PTFD0 &=0x01;

}

-------------Code Ends.

link for DEMO9S08AW60E: http://cache.freescale.com/files/microcontrollers/hardware_tools/schematics/DEMO9S08AW60_SCH.pdf

 

According to the schematic of the board, Switch 4 is connected to PortD/Pin2. And the set of LED are connected to the PortF/Pin(0-7). I have used a pull up resistor with the help of PE. The idea is to switch on the Led when the swtich is pressed.  Logically i feel my code is fine but there doesnt seem to be any effect. I would like to know where i am going wrong and hope you will able to help.

And also it will be great if someone could tell me how to add delay in a loop for example when i am using if else loop.

THANKS in advance!

Outcomes