10 years, 5 months ago.

KL25Z lock-up with 4 PWM channels

There seems to be a problem when we use multiple PWM channels on the KL25Z (Rev D), more specific, with PTA4.
The code below runs fine as long as no loads are connected to the board. When we connect a load to the 4 channels (PTD4, PTA12, PTA4 and PTA5), and apply power to the board, it will run until we press the reset button. This results in a complete lock-up and we need to power cycle the board (Note : the error LED is not blinking). This does not occur when no load is connected to PTA4.
I noticed this problem when I connected the LabTool board (from Embedded Artists) to visualize the PWM channels.
At first, I thought there was a problem with the board, so I used another board and repeated the test. The result was the same (PTA4 causes a lock-up).
I also repeated this test on both boards using an Aimtec LED driver (AMLD-6070Z), same result.

Any idea what is causing this?
Can someone else repeat this test to get it confirmed?

#include "mbed.h"

PwmOut led_r(PTD4);
PwmOut led_g(PTA12);
PwmOut led_b(PTA4);
PwmOut led_w(PTA5);

int main()
{
    float pwmval;
    printf("PWM test.\r\n");
    led_r.period_ms(4);
    led_g.period_ms(4);
    led_b.period_ms(4);
    led_w.period_ms(4);
    led_r = 0.0;
    led_g = 0.0;
    led_b = 0.0;
    led_w = 0.0;
    
    while(1)
    {
        printf("RED.\r\n");
        for(pwmval = 0.0f ; pwmval <= 1.0f ; pwmval += 0.01f)
        {
            led_r = pwmval;
            wait_ms(20);
        }
        printf("GREEN.\r\n");
        for(pwmval = 0.0f ; pwmval <= 1.0f ; pwmval += 0.01f)
        {
            led_g = pwmval;
            wait_ms(20);
        }
        printf("BLUE.\r\n");
        for(pwmval = 0.0f ; pwmval <= 1.0f ; pwmval += 0.01f)
        {
            led_b = pwmval;
            wait_ms(20);
        }
        printf("WHITE.\r\n");
        for(pwmval = 0.0f ; pwmval <= 1.0f ; pwmval += 0.01f)
        {
            led_w = pwmval;
            wait_ms(20);
        }
    }
}

1 Answer

10 years, 5 months ago.

The problem is your load, PTA4 is the NMI (non-maskable interrupt). I assume it pulls the output low, bringing it in an infinite interrupt loop. See: http://mbed.org/questions/1387/How-can-I-access-the-FTFA_FOPT-register-/

Accepted Answer

Oh my, thanks for the reminder, I totally forgot about the NMI input.

posted by Frank Vannieuwkerke 16 Dec 2013