Newbie program question

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi guys,

   

Im just trying to familiarise with the wondeful world of PSoC,

   

I have the PSoC 3210 Eval1 board and ive written a little code that makes an output (connected to an led) go high when an input is low and the output will go low when the input is high (switching off the led)

   

basically i have an output configured which is driven "strong" all the time and its connected via cable to an input which if its high the led will be off and if its low the led will illuminate

   

my code looks a little like this:

   

void main(void)

   

{

   

PRT0DR |= 0X10; //makes P0.4 HIGH, this provides a high signal for the input P0.0

   

while(1)

   

{

   

if (PRT0Dr & 0x01) //checks

   

{

   

PRT1DR &= ~0X01; //toggles output 1.0 which has led connected to show result

   

}

   

else

   

{

   

PRT1DR |= 0X01;

   

}

   

when i power the psoc board up and the input is low the led is on but when i make the input high the output led goes off, the problem is if i make the input low again the led wont illuminate again. I want to be able to make the led go on and off an infinite number of time depending on whether the input is high or low,

   

any help would be appreciated

   

thank you

0 Likes
16 Replies