- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you use the right output type?
how about post your project here for others to check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, how is your LED connected, ie any series resistor?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I change "Drive" in every ports into "Strong"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Dana,
The delay works well.....now I'm gonna do some work for stepper motor....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I do :
P0(0x09);
Delay10msTimes(100);
P0(0x03);
Delay10msTimes(100);
all the LEDs are on, why is that ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.