User manual

54 CY8CKIT-049-4xxx PSoC® 4 Prototyping Kit Guide, Doc. #: 001-90711 Rev. *G
Code Examples
5. Add the following code inside the infinite “for” loop. Note that you need to define a variable ‘uint8
swCounter’ in the beginning of the main loop.
for(;;)
{
/* Reset the software counter if SW1 is not pressed (Pulled high)
*/
if(SW1_Read())
{
swCounter = 0;
}
else
{
/* Increment the counter if SW1 is pressed (Shorted to GND) */
swCounter++;
}
/* Provide a 10 ms delay to make the counter approximately periodic every
10 ms */
CyDelay(10);
/* Check if the software counter has passed 2 s (200 * 10 ms)
==> Since the software counter is incremented only when SW1 is
==> pressed, SW1 is pressed for more than 2 seconds
==> Enter bootloader mode */
if(swCounter > 200)
{
Bootloadable_Load();
}
}
6. Build the project using Build > Build PWMExample01.
7. Program the PSoC 4 device as described from Step 15 in PWMExample on page 43.
8. When the new application is loaded, the output of the project will remain the same as in PWMEx-
ample on page 43. If you press and hold SW1 for 2 seconds without unplugging the device from
the PC, the device will enter bootloader mode (the LED will blink). To exit the bootloader mode,
unplug and re-plug the board from the USB port.