On board LED error

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

cross mob
lock attach
Attachments are accessible only for community members.
IaCa_4674211
Level 3
Level 3
25 replies posted 10 replies posted 10 questions asked

Hi, I am trying to replicate the code posted on https://socmaker.com/?p=296 "Millisecond Timer the easy way", I am using the PSoC CY8CKIT-059 5LP Prototyping Kit, I feel there is something obvious missing, see my attachment, to my way of thinking, looks OK, 

Kind Regards

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I saw the web page.

It seems to be a part of fairly large project.

So I tried to replicate it and made a minimum working set with CY8CKIT-059.

First of all, I think that in that web page, there was not the whole schematic, which includes the pin.

So I created my schematic as below.

The most important point here, IMHO, is naming the output pin "P2_1_Led"

To see the output print out to uart via KitProg, I added UART component.

(Baud rate is set to 115200)

003-schematic.JPG

Then I configured the output pin "P2_1_Led" as below.

002-P2_1_Led.JPG

isr_1ms

005-isr_1ms.JPG

Pins

004-Pins.JPG

main.c

=====================

#include "main.h"

#include "stdio.h"

#define STR_BUF_LEN 64

char str[STR_BUF_LEN+1] ;

void print(char *str)

{

    UART_PutString(str) ;

}

int main(void)

{

    int prev_sec = 0 ;

   

    CyGlobalIntEnable; /* Enable global interrupts. */

    UART_Start() ;

    init_milliseconds() ;

    init_leds() ;

   

    print("\x1b[2J\x1b[;H") ;

    snprintf(str, STR_BUF_LEN, "Led Test (%s %s)\n\r",

        __DATE__, __TIME__) ;

    print(str) ;

   

    for(;;) {

        BlinkLed1(500) ;

        if (prev_sec != seconds) {

            snprintf(str, STR_BUF_LEN, "%02d:%02d:%02d\n\r",

                hours, minutes, seconds) ;

            print(str) ;

            prev_sec = seconds ;

        }

    }

}

=====================

And when the project was build and run

006-TeraTerm-log.JPG

Attached is the project I created.

moto

View solution in original post

0 Likes
10 Replies
BiBi_1928986
Level 7
Level 7
First comment on blog 500 replies posted 250 replies posted

Hello IaCa.

The only way I could replicate the error was by using a pin name in main.c that was different from schematic pin name.  So, this could be the difference in upper/lower case spelling.  Otherwise, the main.c worked for me.  I tested it on KIT-059 (I used slightly different pin names).

So, check that you are using the same pin names in main.c and on your schematic.

BTW, the web link did not work for me.

#include <project.h>

#define LED(a) Pin_2_1_LED_Write(a)

#define SW() Pin_2_2_SW_Read()

int main()

{

    for(;;)

    {

    if (SW() ==0)

       LED(0);

    else

       LED(1);

    }

}

Good luck with your project.

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

Hello, I added the code you posted and got the errors attached to this email,

Kind regards

0 Likes

Hi IaCa.

The errors are because you did not change the pin names on the schematic to match the same pin name in main.c.

Read Len's reply carefully and match up the pin names on the schematic to match the names you are using in main.c.  Len has shown how to create the schematic page along with naming the GPIO output pin with the name that you used, P2_1_Led.  If you're unsure about creating a schematic page, let us know so we can help you through the process.

As to why Creator is giving you the original warnings (that you posted above), we think it's because you have not got matching schematic/main names.  There could be another reason, but I don't know what that is yet.

Keep us updated to your progress.

0 Likes
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

IaCa,

I'm assuming you're concerned about the warnings you are getting:

pastedImage_0.png

If so, you forgot these steps:

Led Setup

Create a new schematic page and name it LED. On the CY8CKIT-059, pin 2[1] is the pin that has an LED attached. Search for Pin in the right hand pane, and select Digital Output Pin [v2.20] or newer. Drag it to the sheet, name it P2_1_Led. Uncheck “HW Connection.” See following:

The Pin on the schematic will lose its green wire an box. This is the visual indication the pin does not need to be attached to any hardware. It is only software controlled.

Connecting Schematic Pin To PSOC Port

Click on Pins in the left hand pane under Design Wide Resources, and select P2[1] for the pin, as follows:

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I saw the web page.

It seems to be a part of fairly large project.

So I tried to replicate it and made a minimum working set with CY8CKIT-059.

First of all, I think that in that web page, there was not the whole schematic, which includes the pin.

So I created my schematic as below.

The most important point here, IMHO, is naming the output pin "P2_1_Led"

To see the output print out to uart via KitProg, I added UART component.

(Baud rate is set to 115200)

003-schematic.JPG

Then I configured the output pin "P2_1_Led" as below.

002-P2_1_Led.JPG

isr_1ms

005-isr_1ms.JPG

Pins

004-Pins.JPG

main.c

=====================

#include "main.h"

#include "stdio.h"

#define STR_BUF_LEN 64

char str[STR_BUF_LEN+1] ;

void print(char *str)

{

    UART_PutString(str) ;

}

int main(void)

{

    int prev_sec = 0 ;

   

    CyGlobalIntEnable; /* Enable global interrupts. */

    UART_Start() ;

    init_milliseconds() ;

    init_leds() ;

   

    print("\x1b[2J\x1b[;H") ;

    snprintf(str, STR_BUF_LEN, "Led Test (%s %s)\n\r",

        __DATE__, __TIME__) ;

    print(str) ;

   

    for(;;) {

        BlinkLed1(500) ;

        if (prev_sec != seconds) {

            snprintf(str, STR_BUF_LEN, "%02d:%02d:%02d\n\r",

                hours, minutes, seconds) ;

            print(str) ;

            prev_sec = seconds ;

        }

    }

}

=====================

And when the project was build and run

006-TeraTerm-log.JPG

Attached is the project I created.

moto

0 Likes

Hello Motoo, Much respect!, Yes, I felt this was part of a larger project, but, given the title "Millisecond Timer the Easy Way",   I was fooled!, I loaded your project and compiled without errors, but does not blink the onboard Led, what could I have missed?

Kind regards

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear IaCa-san,

> I loaded your project and compiled without errors, but does not blink the onboard Led, what could I have missed?

I downloaded my attached project and tried.

On my side of the planet, CY8CKIT-059 is blinking the Blue LED (P2[1]).

It should toggle every 0.5 sec, so the blinking cycle should be about 1sec.

Please download the program and run debug, meantime use some serial terminal program,

such as Tera Term to see if the messages like in my previous response will be shown.

Note: The serial connection does not require the micro-USB connection between CY8CKIT-059 and PC,

but the USB Type-A connection between the KitProg and PC also includes a serial connection.

If you see the messages printed on the serial terminal and the LED still does not blink,

please make sure that you are not connecting some other device(s) via P2[1].

And in case, there is no connection via P2[1], there can be a chance that the LED on your CY8CKIT-059 is broken.

Best Regards,

28-Dec-2020

Motoo Tanaka

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Just to test your on-board LED (P2[1]), I wrote a simple LED Blinker.

Please try it to see if your on-board LED blinks.

schematic

010-schematic.JPG

pins

011-pins.JPG

main.c

======================

#include "project.h"

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    for(;;)

    {

        LED_Write(!LED_Read()) ;

        CyDelay(250) ;

    }

}

======================

moto

0 Likes

Hello Motoo, Yes, I ran the debug and run, this corrected the issue in regards to the led not blinking, I admire your attention to detail!, highly respectable, I am completely new to PSoC, and discovering how useful this can be,

Thank You so much for your help and assistance

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

> I am completely new to PSoC

If it's the case, I wrote the following sample program for those new to PSoC.

Please download and play with it when you have time.

Re: MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-059 version)

Meantime, to understand the concept and the usage of PSoC Creator program,

I would recommend you to watch the following video tutorial(s).

(Note: Although PSoC Family and the board is different from yours,

just watching them will help you to understand how to use these tools.)

https://www.cypress.com/training/psoc-101-video-tutorial-series-how-use-arm-cortex-m0-based-psoc-4

moto

0 Likes