- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Im trying to learn the Psoc basics through datasheets and examples. Got the Psoc 4 Pioneer kit. So far its been okay just one question is bugging me
In such codes when turning a LED on and off when defining the state of the led (1u) is off and (0u) is On? Doesn't this go against everything when 0 is universal known as off and 1 is known as on? Also whats the point of the "u" at the end, I was able to remove it and this had no changes
and
Why are there two quadrature decoders? I compared the TCPWM datasheets and found that the NON TCPWM was much simpler to use and had a better explanation, I am not seeing a reason to use the TCPWM version?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An Led can be connected to any MCU in two configurations:
- Active low, as indicated below:
- Active high, as indicated below:
Depending on how the LED is connected, you need to write a "0" to turn ON an active low LED and a "1" to turn ON an active high LED.
Also, GPIO pins of some of the PSoC devices have higher sink current capability than the amount of current that can be sourced from that pin. Thus, it makes sense to connect the LED in active low configuration for such pins and write a "0" to drive the LED ON.
"u" just stands for unsigned. It's just a best practice to add "u" after all unsigned literals. Refer this stack overflow post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A LED can be connected as "Active Low" or as "Active High". This reflects the state (0 or 1) that has to be written to the pin to let the LED light. I use frequently in my code
#define ActiveHigh | TRUE | // LEDs are active high in this application | ||||||||||
#define LEDOFF | !LEDON | |||||||||||
#define LEDON | ActiveHigh |
There are some more components that have different underlying hardware. UDB based components and TCPWM based ones.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An Led can be connected to any MCU in two configurations:
- Active low, as indicated below:
- Active high, as indicated below:
Depending on how the LED is connected, you need to write a "0" to turn ON an active low LED and a "1" to turn ON an active high LED.
Also, GPIO pins of some of the PSoC devices have higher sink current capability than the amount of current that can be sourced from that pin. Thus, it makes sense to connect the LED in active low configuration for such pins and write a "0" to drive the LED ON.
"u" just stands for unsigned. It's just a best practice to add "u" after all unsigned literals. Refer this stack overflow post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As user_1377889 stated, the underlying hardware for the two components is different. Depending on your application and space/hardware that is already used in your project, then you may prefer/choose one over the other.
(UDB is generally more general-purpose from what I've seen)
The 'u' at the end of the 1 and 0 is to designate an unsigned integer; This is a basic programming fundamental: Integer (computer science) - Wikipedia
And as the other replies stated, the 1 and 0 reflect the voltage/current output of the GPIO pin, but the LED itself may be connect to either a ground or power rail on the other side, thus leading to a sink/source of current to turn on the LED.