8 Replies Latest reply on Aug 11, 2016 12:09 PM by JoYa_1675071

    PRoC PWM Drive to LED : Powerup State Control Problem

    JoYa_1675071

      I am controlling an LED's brightness using TCPWM line out to drive the cathode with the LEDs anode connected to VCC. I am also running BLE stack.

         

      When the PRoC CYBLE-022001-00 first powers up, the LED is turned on for a while until the PWM is initialized to generate a high output on it's 'line' port... which I connected to an output pin.

         

      How can I set the PWM components 'line' output to be high at initial powerup of the module?

         

      How do I see the ARMs program memory opcode to single step starting from it's reset vector address at powerup?

         

      It seems there is startup code executing which is esoteric and non-alterable to the programmer which makes me question exactly how much control is exposed to the designer in these GUI based IDEs. This lack of startup control anomaly is a classic example.

        • 1. Re: PRoC PWM Drive to LED : Powerup State Control Problem
          JoMe_264151

          Welcome in the forum, no need for paranoia,

             

          Have a look into the cyboot component described in the "System Reference Guide" from creator help menu. Additionally go through the generated cyboot sources to see what happens there.

             

          To start debugging from reset check the right option in Creator -> Tools -> Program/Debug -> General.

             

          By the way: Debugging is meant to find errors and eliminate them, do you suspect any bugs in the startup code?

             

          For your LED: Use the negated output of the PWM, will need some calculations for setting the brightness.

             

           

             

          Happy debugging ;-)

             

          Bob

          • 2. Re: PRoC PWM Drive to LED : Powerup State Control Problem
            JoYa_1675071

            Can not move LED control pin to negated PWM output due to PRoC routing limitations. Therefore, selected "Output line signal: Inverse output" option in TCPWM config GUI.

               

            The PWM output pin does indeed go high when resetting to reset vector. After __libc_init_array() is called in Cm0Start.c, the PWM output pin goes low turning on the LED. Trying to step into __libc_init_array() during debug does not work and it steps over the function. Can't find this extern defined routine when searching the workspace... to determine the issue. Classic.

               

            Update: I just tried using the negated output pin of the PWM, and it also goes low during powerup. So, both the non-negated and negated outputs of the PWM go low during powerup. Therefore, they are not complements to each other.

               

            How many other components have unpredictable/uncontrollable behavior during powerup? Can this problem be solved in the GUI IDE, or do I need external circuitry to control the startup behavior of PRoC module pins?

               

             

               

            New discovery: If I choose a PWM output pin that does NOT support a negative PWM output selection (ie.. TCPWM[0].line_out of which there is no selection for TCPWM[0].line_out_compl), the component works properly. So, looks like dual output PWM instantiations do not properly execute correct levels on startup.

            • 3. Re: PRoC PWM Drive to LED : Powerup State Control Problem
              JoMe_264151

              You should have a look into AN60616 which describes the startup procedure for PSoC3 and 5. This is also applicable to PSoC4 chips-

                 

              Before the components have been initialized all pins are in high-z state. To overcome your problem, I would suggest to initially configure your LED-pin to high-z and at the time you start(ed) the PWM set the pin's configuration to your required drive mode using Pin_SetDriveMode() API.

                 

               

                 

              Bob

              • 4. Re: PRoC PWM Drive to LED : Powerup State Control Problem
                JoMe_264151

                Attach your project so I can make my suggested changes.To do so, use
                Creator->File->Create Workspace Bundle (minimal)
                and attach the resulting file.

                   

                 

                   

                Bob

                • 5. Re: PRoC PWM Drive to LED : Powerup State Control Problem
                  JoYa_1675071

                  OK.. thanks. See attached config that was req'd. Hopefully, the additional Qty-2 LED colors PWM drivers will work the same. (ie.. CREE LED used on the BLE Pioneer kit).

                     

                  • 7. Re: PRoC PWM Drive to LED : Powerup State Control Problem
                    JoMe_264151

                    You have defined an analog pin for the blue LED. As my experiences are: this will not work.

                       

                     

                       

                    Bob

                    • 8. Re: PRoC PWM Drive to LED : Powerup State Control Problem
                      JoYa_1675071

                      OK. See below verbatim comment from Cy tech support:

                         


                      You don't want the LED to be turned on for a small duration after reset/bootup. Have I understood your question correctly?

                         

                      If that is the case, there is a simple workaround:

                         

                      a) Configure the Pin to 'High Impedance Analog' in the configuration window of the pin.

                         

                      b) Use the Pin_SetDriveMode() API in your program after your PWM has started, and change the drive mode to whatever you prefer.
                       

                         

                      I reverted config GUI define to digital output : HW connection type w/ Hi-Z digital drive mode and it works too.