6 Replies Latest reply on Nov 23, 2018 10:04 PM by user_13463998

    Psoc Creator LED code not working

    info_3697476

      I am trying to get code that turns a LED on in Psoc Creator to work but I'm getting the following errors on the bottom image. I checked the configuration of the LED and don't think that's the cause of the issue. Any suggestions?

      image (3).png

      image (1).png

      image (2).png

      image.png

        • 1. Re: Psoc Creator LED code not working
          OwenZ_26

          Please uncheck the "HW connection" box as you don't connect the pin to anywhere.

          1 of 1 people found this helpful
          • 2. Re: Psoc Creator LED code not working
            user_13463998

            Hi,

             

            In many evaluation boards, the logic of LED is negative,

            which means you must write '0' to turn it on.

            Anyway to give a try, how about doing?

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

            while(1) {

                 LEDG_Write(1) ;

                 CyDelay(500) ;

                 LEDG_Write(0) ;

                 CyDelay(500) ;

            }

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

             

            moto

            1 of 1 people found this helpful
            • 3. Re: Psoc Creator LED code not working
              info_3697476

              Hi I unchecked the HW box and the errors below still occur.

              image.png

              • 4. Re: Psoc Creator LED code not working
                user_13463998

                Hi,

                 

                Since you un-checked the HW box, in the schematic there should not be a wire left.

                So the schematic will look like...

                001-schematic.JPG

                My pin configuration is like yours, but please note I set "Initial drive state" to "High(1)"

                so that the LED is off when the program starts.

                000-pin-LEDG.JPG

                 

                Then I assign LEDG to pin P2[6] for CY8CKIT-044, (change the pin according to your board.)

                002-Pins.JPG

                 

                Then after generating application, edit main.c something like below.

                Note, I define LED_ON as 0u.

                003-Source.JPG

                Then when I select debug and run, my CY8CKIT-044 blinks Green LED on and off.

                Attached is my test project.

                 

                Meantime, I strongly recommend you to watch the "PSoC 101 Video Tutorial Series"

                they are worth for the time and save you a lot of time later.

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

                 

                moto

                1 of 1 people found this helpful
                • 5. Re: Psoc Creator LED code not working
                  info_3697476

                  Hi Motoo,

                   

                  Thanks for your help! I got the LEDs to work, but now am encountering issues getting the code in the C file attached to work in my board. My PCB is using a PSoC 4000S and I managed to compile and flash the code onto the board, but the LED is not blinking when activating the sensor at the pin designated 'VELO' .

                   

                  After I tried activating the sensor a few times the PCB became unresponsive to my KitProg programmer and the PSoc software. I will solder a new board, but do you have any suggestions as to why the PSoC ADC isn't behaving as it should with the flashed code?

                   

                  image (1).png

                  image.png

                  • 6. Re: Psoc Creator LED code not working
                    user_13463998

                    Hi,

                     

                    > Thanks for your help!

                    > I got the LEDs to work,

                    I'm glad hearing that!

                    I'd appreciate it if you mark my reply as correct answer.

                     

                    > but now am encountering issues getting the code

                    > in the C file attached to work in my board.

                    Now you are asking a very different question from the original question.

                     

                    Especially question(s) about CapSense is, IMHO, not a trivial one,

                    Then I'd strongly ask you to post a new question with an appropriate title,

                    so that those "CapSense Experts" can help you.

                     

                    Having written that, although I'm not very familiar with CapSense,

                    if I were you, I would modify the main.c something like below.

                     

                    My points are

                    (1) check if the CapSense_ADC is busy or not by using

                            if (CapSense_ADC_NOT_BUSY == CapSense_ADC_IsBusy()) {

                     

                    (2) move CapSense_ADC_ScanAllWidgets() inside the loop at the end of the loop,

                    since you have already called one just before the loop.

                     

                    (3) I would separate process between STATE_ADC and STATE_CAPSENSE

                     

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

                    int main (void)

                    {

                        CyGlobalIntEnable; // Enable global interrupts

                       //modified from the example program (CE210311 http://www.cypress.com/file/230881/download) )

                     

                       /* Start CapSense_ADC component */

                     

                       CapSense_ADC_Start();

                       CapSense_ADC_ScanAllWidgets();

                       scanState = STATE_ADC;

                     

                    // move this to the begining of main()   CyGlobalIntEnable; // Enable global interrupts

                       VELO_Write(1);

                       while(1) {

                            if (CapSense_ADC_NOT_BUSY == CapSense_ADC_IsBusy()) {

                                if (scanState == STATE_ADC) {

                                   CapSense_ADC_RunTuner();

                    //               CapSense_ADC_ScanAllWidgets();

                                    mVolts = CapSense_ADC_AdcGetResult_mVolts(CapSense_ADC_AdcCHANNEL_0);

                     

                                    CapSense_ADC_AdcStartConvert(CapSense_ADC_AdcCHANNEL_0);

                     

                    //                CapSense_ADC_ProcessAllWidgets();

                                    scanState = STATE_CAPSENSE;

                         

                                //quick test of ADC - indicate whether the ADC detects something less than a threshold

                                //when sensor at VELO pin detects < 400u mVolts the green LED at LEDG will blink

                                    if(mVolts < 400u){

                                        LEDG_Write(1);

                                        CyDelay(500);

                                        LEDG_Write(0);

                                    }

                         

                                //else the green LED will not blink

                         

                                    else{

                                        LEDG_Write(0);

                                    }

                                } else if (scanState == STATE_CAPSENSE) {

                                    CapSense_ADC_ProcessAllWidgets() ;

                                    if (CapSense_ADC_IsAnyWidgetActive()) {

                                        mVolts = CapSense_ADC_AdcGetResult_mVolts(CapSense_ADC_AdcCHANNEL_0);  

                                        /* do process for STATE_CAPSENSE, here */

                                    }

                                }

                                CapSense_ADC_ScanAllWidgets() ;

                            }

                        }

                    }

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

                     

                    I'm not sure if this solve you the problem,

                    and you probably need to get help from those experts CapSense.

                     

                    moto