1
\$\begingroup\$

I am using Infineon Dave v4.2.2. to program the XMC1200 boot kit with colour LED card to read a DMX input signal using a rotary dial.

For those that don' know, Dave uses a simple UI with "apps" that will auto-generate code for you. I have successfully worked through Infineon's example for a 3-channel RGB LED with DMX control, found here:

Infineon DMX512 App Overview

XMC1200 CPU Card User Manual

Color Card User Manual


main.c code from 3 RGB Lamps Example using PDM_DIMMED_LED_LAMP APPs

#include <DAVE.h>                 //Declarations from DAVE Code Generation (includes SFR declaration)

#define LINEAR_WALK_PRESCALER 0x2AC // prescaler value for walk time of 7s
#define DIM_DIV 0x64 // dimdiv value for dimming transition of 7s
#define DIM_PS  0xDB // dimclk_ps value

void OneSecTick(void);

/**

 * @brief main() - Application entry point
 *
 * <b>Details of function</b><br>
 * This routine is the application entry point. It is invoked by the device startup code. It is responsible for
 * invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
 * code.
 */

int main(void)
{
  DAVE_STATUS_t status;
  uint32_t TimerId;

  status = DAVE_Init();           /* Initialization of DAVE APPs  */

  if(status == DAVE_STATUS_FAILURE)
  {
    /* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
    XMC_DEBUG("DAVE APPs initialization failed\n");

    while(1U)
    {

    }
  }

  TimerId = SYSTIMER_CreateTimer(1000000, SYSTIMER_MODE_PERIODIC, (SYSTIMER_CALLBACK_t) OneSecTick, NULL);
  SYSTIMER_StartTimer(TimerId);

  /* Placeholder for user application code. The while loop below can be replaced with user application code. */
  while(1U)
  {

  }
}

void OneSecTick(void)
{
  static uint8_t step = 0;

  if (++step==1) {
    /* Change Slowly to Red */
    RGB_LAMP_1_config.led_intensity[0] = 4095;
    RGB_LAMP_1_config.led_intensity[1] = 0;
    RGB_LAMP_1_config.led_intensity[2] = 0;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_1, LINEAR_WALK_PRESCALER);

    /* Change Slowly to Green */
    RGB_LAMP_2_config.led_intensity[0] = 0;
    RGB_LAMP_2_config.led_intensity[1] = 4095;
    RGB_LAMP_2_config.led_intensity[2] = 0;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_2, LINEAR_WALK_PRESCALER);

    /* Change Slowly to Blue */
    RGB_LAMP_3_config.led_intensity[0] = 0;
    RGB_LAMP_3_config.led_intensity[1] = 0;
    RGB_LAMP_3_config.led_intensity[2] = 4095;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_3, LINEAR_WALK_PRESCALER);
  }
  else if (step==9) {
    /* Change Slowly to Green */
    RGB_LAMP_1_config.led_intensity[0] = 0;
    RGB_LAMP_1_config.led_intensity[1] = 4095;
    RGB_LAMP_1_config.led_intensity[2] = 0;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_1, LINEAR_WALK_PRESCALER);

    /* Change Slowly to Blue */
    RGB_LAMP_2_config.led_intensity[0] = 0;
    RGB_LAMP_2_config.led_intensity[1] = 0;
    RGB_LAMP_2_config.led_intensity[2] = 4095;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_2, LINEAR_WALK_PRESCALER);

    /* Change Slowly to White */
    RGB_LAMP_3_config.led_intensity[0] = 1365;
    RGB_LAMP_3_config.led_intensity[1] = 1365;
    RGB_LAMP_3_config.led_intensity[2] = 1365;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_3, LINEAR_WALK_PRESCALER);
  }
  else if (step==17) {
    /* Change Slowly to Blue */
    RGB_LAMP_1_config.led_intensity[0] = 0;
    RGB_LAMP_1_config.led_intensity[1] = 0;
    RGB_LAMP_1_config.led_intensity[2] = 4095;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_1, LINEAR_WALK_PRESCALER);

    /* Change Slowly to White */
    RGB_LAMP_2_config.led_intensity[0] = 1365;
    RGB_LAMP_2_config.led_intensity[1] = 1365;
    RGB_LAMP_2_config.led_intensity[2] = 1365;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_2, LINEAR_WALK_PRESCALER);

    /* Dim Down Slowly to 0% */
    RGB_LAMP_3_config.dim_level = 0;
    PDM_DIMMED_LED_LAMP_SetDimLevelExponentialAdv(&RGB_LAMP_3, DIM_DIV, DIM_PS);
  }
  else if (step==25) {
    /* Change Slowly to White */
    RGB_LAMP_1_config.led_intensity[0] = 1365;
    RGB_LAMP_1_config.led_intensity[1] = 1365;
    RGB_LAMP_1_config.led_intensity[2] = 1365;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_1, LINEAR_WALK_PRESCALER);

    /* Dim Down Slowly to 0% */
    RGB_LAMP_2_config.dim_level = 0;
    PDM_DIMMED_LED_LAMP_SetDimLevelExponentialAdv(&RGB_LAMP_2, DIM_DIV, DIM_PS);

    /* Dim Up Slowly to 25% */
    RGB_LAMP_3_config.dim_level = 1024;
    PDM_DIMMED_LED_LAMP_SetDimLevelExponentialAdv(&RGB_LAMP_3, DIM_DIV, DIM_PS);
  }
  else if (step==33) {
    /* Dim Down Slowly to 0% */
    RGB_LAMP_1_config.dim_level = 0;
    PDM_DIMMED_LED_LAMP_SetDimLevelExponentialAdv(&RGB_LAMP_1, DIM_DIV, DIM_PS);

    /* Dim Up Slowly to 25% */
    RGB_LAMP_2_config.dim_level = 1024;
    PDM_DIMMED_LED_LAMP_SetDimLevelExponentialAdv(&RGB_LAMP_2, DIM_DIV, DIM_PS);

    /* Change Slowly to Red */
    RGB_LAMP_3_config.led_intensity[0] = 4095;
    RGB_LAMP_3_config.led_intensity[1] = 0;
    RGB_LAMP_3_config.led_intensity[2] = 0;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_3, LINEAR_WALK_PRESCALER);
  }
  else if (step==40) {
    /* Dim Up Slowly to 25% */
    RGB_LAMP_1_config.dim_level = 1024;
    PDM_DIMMED_LED_LAMP_SetDimLevelExponentialAdv(&RGB_LAMP_1, DIM_DIV, DIM_PS);

    /* Change Slowly to Red */
    RGB_LAMP_2_config.led_intensity[0] = 4095;
    RGB_LAMP_2_config.led_intensity[1] = 0;
    RGB_LAMP_2_config.led_intensity[2] = 0;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_2, LINEAR_WALK_PRESCALER);

    /* Change Slowly to Green */
    RGB_LAMP_3_config.led_intensity[0] = 0;
    RGB_LAMP_3_config.led_intensity[1] = 4095;
    RGB_LAMP_3_config.led_intensity[2] = 0;
    PDM_DIMMED_LED_LAMP_SetColorAdv(&RGB_LAMP_3, LINEAR_WALK_PRESCALER);
  }
  else if (step==47) {
    step = 0;
  }
}

This works perfectly, but I am interested in implementing RGBW control, which will require a 4th channel.

Therefore, I assumed I would have to change the number of LEDs from 3 to 4 under the PDM_DIMMED_LAMP app, assign a pin to the new LED, update the number of relevant slots in the DMX512 app from 3 to 4, add a new line in the code to gather 8-bit data for the new LED (I am using the BLUE part on the 2nd RGB LED as a stand-in for white), and then run the code.

However, when I change the number of relevant slots from 3 to 4, all 4 channels light up but they stop responding to the dimmer.

Could this be a dimmer issue?

If anyone has any suggestions as to why this might be happening, it would be much appreciated.

    Copyright (c) 2016, Infineon Technologies AG                                 **
 All rights reserved.                                                         **
                                                                              **
 Redistribution and use in source and binary forms, with or without           **
 modification,are permitted provided that the following conditions are met:   **
                                                                              **
 *Redistributions of source code must retain the above copyright notice,      **
 this list of conditions and the following disclaimer.                        **
 *Redistributions in binary form must reproduce the above copyright notice,   **
 this list of conditions and the following disclaimer in the documentation    **
 and/or other materials provided with the distribution.                       **
 *Neither the name of the copyright holders nor the names of its contributors **
 may be used to endorse or promote products derived from this software without**
 specific prior written permission.                                           **
                                                                              **
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  **
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE    **
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE   **
 ARE  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE   **
 LIABLE  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR         **
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF         **
 SUBSTITUTE GOODS OR  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS    **
 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN      **
 CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)       **
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE   **
 POSSIBILITY OF SUCH DAMAGE.                                                  **
                                                                              **
 To improve the quality of the software, users are encouraged to share        **
 modifications, enhancements or bug fixes with Infineon Technologies AG       **
 dave@infineon.com).                                                          **
                                                                              **
********************************************************************************
**                                                                            **
**                                                                            **
** PLATFORM : Infineon XMC1000 Series                                         **
**                                                                            **
** AUTHOR : Application Engineering Team                                      **
**                                                                            **
**                                                                            **
** version 1 (first version)                                                  **
** version 2 (migration to DAVE v4)                                           **
** MODIFICATION DATE : June, 17, 2016                                         **
**                                                                            **
*******************************************************************************/
#include <DAVE.h>                 //Declarations from DAVE Code Generation (includes SFR declaration)

/**

 * @brief main() - Application entry point
 *
 * <b>Details of function</b><br>
 * This routine is the application entry point. It is invoked by the device startup code. It is responsible for
 * invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
 * code.
 */

int main(void)
{
  DAVE_STATUS_t status;

  status = DAVE_Init();           /* Initialization of DAVE APPs  */

  if(status == DAVE_STATUS_FAILURE)
  {
    /* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
    XMC_DEBUG("DAVE APPs initialization failed\n");

    while(1U)
    {

    }
  }

  /* initialize global dimming level to 100% */
  XMC_BCCU_SetGlobalDimmingLevel(BCCU0, 4095U);

  /* Placeholder for user application code. The while loop below can be replaced with user application code. */
  while(1U)
  {

  }
}

void DMX512_RD_UserCallBack(void)
{
  RGB_LAMP.config->led_intensity[0] = DMX512_RD_0_rx_array[0] << 4U; // 8-bit information for Red color
  RGB_LAMP.config->led_intensity[1] = DMX512_RD_0_rx_array[1] << 4U; // 8-bit information for Green color
  RGB_LAMP.config->led_intensity[2] = DMX512_RD_0_rx_array[2] << 4U; // 8-bit information for Blue color
  PDM_DIMMED_LED_LAMP_SetColor(&RGB_LAMP);
}

This is the code generated in the DMX512 infineon example, available from the website, for the 3-channel RGB LED w/DMX512 control (link no. 1 above).

enter image description here

This is a screenshot from the UI of the DMX512 app

Its probably worth noting I have a DMX dimmer, as well as the XMC1200 boot kit, which is essential for this project to work.

\$\endgroup\$
0
\$\begingroup\$

The easy way to use one RGB and the blue of another is to use the white app
" 4-Channel White LED Lamp Example using XMC LibEN"

This will map RG and B of RGB_LAMP_2 and blue or RGB_LAMP_2 with the 4 white strings.

Notice how BCCUPUT0-4 are wired.


white Board
enter image description here


Color Board
enter image description here


I assumed I would have to change the number of LEDs from 3 to 4 under the PDM_DIMMED_LAMP app, assign a pin to the new LED, update the number of relevant slots in the DMX512 app from 3 to 4, add a new line in the code to gather 8-bit data for the new LED

I would not have changed the number of LEDs from 3 to 4.

I would just use RGB_LAMP_2_config.led_intensity[0] as the "white" LED.

when I change the number of relevant slots from 3 to 4, all 4 channels light up but they stop responding to the dimmer.

Need you to be more specific about "slot".
You changed what in which file?


You can't just change the dimensions on RGB_LAMP_1_config.led_intensity from 3 to 4.
You must then associate RGB_LAMP_1_config.led_intensity[3] to the CPU I/O pin.
And disassociate RGB_LAMP_2_config.led_intensity[0] from that CPU pin.


It will not be easy to create RGB_LAMP_1_config.led_intensity[3]

The configuration spans across a number of files.

The no_of_leds_used is used to configure all 3 RGB LEDs.

In file \PDM_DIMMED_LED_LAMP_DIRECT_PDM_3RGB_EXAMPLE_XMC12\Dave\Generated\PDM_DIMMED_LED_LAMP\pdm_dimmed_led_lamp.c

 for (count = 0U; count < handle->no_of_leds_used; count++)

Then the gpio pins used are configured as

const PDM_DIMMED_LED_LAMP_GPIO_COMPOUT_CONFIG_t const *gpio_config_out[9];
const PDM_DIMMED_LED_LAMP_GPIO_CCUIN_CONFIG_t const *gpio_config_in[9];
\$\endgroup\$
1
  • \$\begingroup\$ First of all, thank you for your comprehensive answer. The "slots" I am referring to are in the DMX512_RD app. Since this is for an RGBW application, using DMX512 protocol to allow the user to specify the colour of the LEDs, I cannot map two colours to the same channel unfortunately, it needs to control 4 separate channels of LEDs. Admittedly, I am not completely sure what I am doing with the slots, I will look further into it. I can't post pictures in the comments so I will post screenshots of all relevant information in the original question. \$\endgroup\$ Dec 6 '18 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.