LED so dim on PSOC 1

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

cross mob
Anonymous
Not applicable

Guys,

   

 

   

I tried to blink those LED on PSOC, but the LEDs are so dim,

   

Does anyone know why ?

   

 

   

Here's the code :

   

 

   

//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------

#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules
#include "delay.h"
#include "ports.h"
#include "bits.h"

void main(void)
{
  unsigned int i;                     /* Delay var */
  unsigned char j;                    /* LED var */
  while(1)
   {
 
    P0_0(0); //Turns the LED Off.
    P0_1(0);
    P0_2(0);
    P0_3(0);
   
    Delay10msTimes(100);
    P0_0(1); //Turns the LED On.
    P0_1(1);
    P0_2(1);
    P0_3(1);
   
   
  }
}
 

   

 

   

Thanks for reading and helping

0 Likes
14 Replies
Anonymous
Not applicable

 Do you use the right output type?

   

how about post your project here for others to check.

0 Likes
Anonymous
Not applicable

 Also, how is your LED connected, ie any series resistor?

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

yes with series resistor, I uploaded the project below

0 Likes
Anonymous
Not applicable

I change "Drive" in every ports into "Strong"

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You are turning off the LED, waiting 1q0 mS, turning on, doing

   

an immeadiate loop and turning it right back off.

   

 

   

Change from this -

   

 

   

  while(1)
{

P0_0(0); //Turns the LED Off.
P0_1(0);
P0_2(0);
P0_3(0);

Delay10msTimes(100);
P0_0(1); //Turns the LED On.
P0_1(1);
P0_2(1);
P0_3(1);
    
  }
 

   

 

   

to this -

   

 

   

  while(1)
{

P0_0(0); //Turns the LED Off.
P0_1(0);
P0_2(0);
P0_3(0);

Delay10msTimes(100);
P0_0(1); //Turns the LED On.
P0_1(1);
P0_2(1);
P0_3(1);

   

Delay10msTimes(100);
    
    
  }
 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Bianchi, I would suggest you to upgrade your PSoC Designer to the latest version which is now 5.3 (you are using 5.1). Not only some bugs were corrected, there are new features as rubber-banding and creation of archives and there are new components, too.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I think Bob is refering to rubber banding in PSOC creator. Designer has re-instated from an

   

older version the route possibilities -

   

 

   

   

 

   

http://www.cypress.com/?rID=41083

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Thanks Dana,

   

The delay works well.....now I'm gonna do some work for stepper motor....

0 Likes
Anonymous
Not applicable

if i define :

   

#define P0(b)   (PRT0DR = (b==0) ? 0x00 : 0xFF)

   

 

   

can I write :

   

 

   

P0(0x0C);

   

I tried to run it but I can not see "C" on the P0

   

I should be able to see the LED on the position "1100"

   

P0.0 = 0

   

P0.1 = 0

   

P0.2 = 1

   

P0.3 = 1

   

 

   

Anyone has idea ?

   

thanks

0 Likes
Anonymous
Not applicable

When I do :

   

P0(0x09);
                Delay10msTimes(100);
                P0(0x03);
                Delay10msTimes(100);

   

 

   

all the LEDs are on, why is that ?

0 Likes
ArvindK_86
Employee
Employee
10 sign-ins 5 sign-ins 10 solutions authored

 Hi,

   

 

   

If you simply want 0x0C on the Port, why not write PRT0DR = 0x0C.

   

If you have other pins on the port to which you dont want to write to, use a mask or shadow registers.

   

 

   

I see that you're trying to use macros/function to set one pin at a time. For that a more suitable code would be 

   

 

   

void SetPin(BYTE pinNumber, BYTE value)

   

{

   

if (value == 1)

   

{

   

    PRT0DR |= (1 << pinNumber);

   

}

   

else

   

{

   

    PRT0DR &= ~(1 << pinNumber);

   

}

   

}

0 Likes
ArvindK_86
Employee
Employee
10 sign-ins 5 sign-ins 10 solutions authored

When you use the macro 

   

#define P0(b)   (PRT0DR = (b==0) ? 0x00 : 0xFF)

   

 

   

is means that PRT0DR will be 0x00 if b==0 else it will be 0xFF. 

   

 

   

That's why all your pins are high.

0 Likes
Anonymous
Not applicable

thanks for the reply,

   

 

   

How can I define it then if I wanna say

   

P0(0x0C);

   

 

   

what should I modify from this line ?

   

#define P0(b)   (PRT0DR = (b==0) ? 0x00 : 0xFF)

   

 

   

is it

   

 

   

#define P0(b)   (PRT0DR = b)

   

 

   

?

   

 

   

Thank you

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If you need per pin control a handy module is the LED module. Allows you to write/read, takes

   

care of shadow registers (if you have mixed I/O in a port shadow registers make sure Read

   

modify Write activity logically returns correct values).

   

 

   

http://www.cypress.com/?rID=2900

   

 

   

Regards, Dana.

0 Likes