Topics

FRDM-K64 PWM BUS Fault


Anders Dam Kofoed <adk@...>
 

Hi all,

I am trying to use the PWM output on the K64 board. I have taken the sample/drivers/pwm_dw/src/main.c and modified it to use the CONFIG_PWM_K64_FTM_0_DEV_NAME and removed the CONFIG_PWM_DW=y from the prj.conf. Compiles without errors or warnings. Using the latest 0.75 SDK and zephyr-project code I get this on the terminal when running it:

PWM demo app
***** BUS FAULT *****
Executing thread ID (thread): 0x20001b28
Faulting instruction address: 0x00000b78
Imprecise data bus error
Fatal fault in task ! Aborting task.

---
prj.conf:
---
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_NANO_TIMERS=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_GPIO=y
CONFIG_PWM=y
---

CODE:
---
#include <zephyr.h>

#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif

#include <device.h>
#include <pwm.h>
#include <sys_clock.h>

/* about 1 ms */
#define MIN_PERIOD 32000

/* about 1 second */
#define MAX_PERIOD 32000000

#define SLEEPTICKS SECONDS(4)

void main(void)
{
struct nano_timer timer;
void *timer_data[1];
struct device *pwm_dev;
uint32_t period;
uint8_t dir;

nano_timer_init(&timer, timer_data);

PRINT("PWM demo app\n");

pwm_dev = device_get_binding(CONFIG_PWM_K64_FTM_0_DEV_NAME);
if (!pwm_dev) {
PRINT("Cannot find %s!\n", CONFIG_PWM_K64_FTM_0_DEV_NAME);
}

period = MAX_PERIOD;
dir = 0;

while (1) {
pwm_pin_set_values(pwm_dev, 0, period, period);
//pwm_pin_set_duty_cycle(pwm_dev, 0, 40);

if (dir) {
period *= 2;

if (period > MAX_PERIOD) {
dir = 0;
period = MAX_PERIOD;
}
} else {
period /= 2;

if (period < MIN_PERIOD) {
dir = 1;
period = MIN_PERIOD;
}
}

nano_timer_start(&timer, SLEEPTICKS);
nano_timer_test(&timer, TICKS_UNLIMITED);
}
}

I have found another way to do what I want so no rush. Just wanted to state that it's not working.

Kind regards
Anders Dam Kofoed


Kalowsky, Daniel <daniel.kalowsky@...>
 

I'd encourage you to file a JIRA/bug so that we can track this and get someone looking at it.

-----Original Message-----
From: Anders Dam Kofoed [mailto:adk(a)accipio.dk]
Sent: Wednesday, March 23, 2016 8:01 AM
To: devel(a)lists.zephyrproject.org
Subject: [devel] FRDM-K64 PWM BUS Fault

Hi all,

I am trying to use the PWM output on the K64 board. I have taken the
sample/drivers/pwm_dw/src/main.c and modified it to use the
CONFIG_PWM_K64_FTM_0_DEV_NAME and removed the
CONFIG_PWM_DW=y from the prj.conf. Compiles without errors or
warnings. Using the latest 0.75 SDK and zephyr-project code I get this on the
terminal when running it:

PWM demo app
***** BUS FAULT *****
Executing thread ID (thread): 0x20001b28
Faulting instruction address: 0x00000b78
Imprecise data bus error
Fatal fault in task ! Aborting task.

---
prj.conf:
---
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_NANO_TIMERS=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_GPIO=y
CONFIG_PWM=y
---

CODE:
---
#include <zephyr.h>

#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif

#include <device.h>
#include <pwm.h>
#include <sys_clock.h>

/* about 1 ms */
#define MIN_PERIOD 32000

/* about 1 second */
#define MAX_PERIOD 32000000

#define SLEEPTICKS SECONDS(4)

void main(void)
{
struct nano_timer timer;
void *timer_data[1];
struct device *pwm_dev;
uint32_t period;
uint8_t dir;

nano_timer_init(&timer, timer_data);

PRINT("PWM demo app\n");

pwm_dev =
device_get_binding(CONFIG_PWM_K64_FTM_0_DEV_NAME);
if (!pwm_dev) {
PRINT("Cannot find %s!\n",
CONFIG_PWM_K64_FTM_0_DEV_NAME);
}

period = MAX_PERIOD;
dir = 0;

while (1) {
pwm_pin_set_values(pwm_dev, 0, period, period);
//pwm_pin_set_duty_cycle(pwm_dev, 0, 40);

if (dir) {
period *= 2;

if (period > MAX_PERIOD) {
dir = 0;
period = MAX_PERIOD;
}
} else {
period /= 2;

if (period < MIN_PERIOD) {
dir = 1;
period = MIN_PERIOD;
}
}

nano_timer_start(&timer, SLEEPTICKS);
nano_timer_test(&timer, TICKS_UNLIMITED);
}
}

I have found another way to do what I want so no rush. Just wanted to state
that it's not working.

Kind regards
Anders Dam Kofoed


Maciek Borzecki <maciek.borzecki@...>
 

On Wed, Mar 23, 2016 at 4:01 PM, Anders Dam Kofoed <adk(a)accipio.dk> wrote:
Hi all,

I am trying to use the PWM output on the K64 board. I have taken the sample/drivers/pwm_dw/src/main.c and modified it to use the CONFIG_PWM_K64_FTM_0_DEV_NAME and removed the CONFIG_PWM_DW=y from the prj.conf. Compiles without errors or warnings. Using the latest 0.75 SDK and zephyr-project code I get this on the terminal when running it:

PWM demo app
***** BUS FAULT *****
Executing thread ID (thread): 0x20001b28
Faulting instruction address: 0x00000b78
Imprecise data bus error
Fatal fault in task ! Aborting task.
Full assembly listing in written to outdir/zephyr.lst. Having the
address of instruction that trigger the fault, try looking it up in
the listing and see if there's something obviously wrong. The assembly
will be mixed with C, you can try a debug build to get an unoptimized
version which should be a bit easier to look at . If nothing in
particular stands out, you can always try gdb.

---
prj.conf:
---
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_NANO_TIMERS=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_GPIO=y
CONFIG_PWM=y
---

CODE:
---
#include <zephyr.h>

#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define PRINT printf
#else
#include <misc/printk.h>
#define PRINT printk
#endif

#include <device.h>
#include <pwm.h>
#include <sys_clock.h>

/* about 1 ms */
#define MIN_PERIOD 32000

/* about 1 second */
#define MAX_PERIOD 32000000

#define SLEEPTICKS SECONDS(4)

void main(void)
{
struct nano_timer timer;
void *timer_data[1];
struct device *pwm_dev;
uint32_t period;
uint8_t dir;

nano_timer_init(&timer, timer_data);

PRINT("PWM demo app\n");

pwm_dev = device_get_binding(CONFIG_PWM_K64_FTM_0_DEV_NAME);
if (!pwm_dev) {
PRINT("Cannot find %s!\n", CONFIG_PWM_K64_FTM_0_DEV_NAME);
}

period = MAX_PERIOD;
dir = 0;

while (1) {
pwm_pin_set_values(pwm_dev, 0, period, period);
//pwm_pin_set_duty_cycle(pwm_dev, 0, 40);

if (dir) {
period *= 2;

if (period > MAX_PERIOD) {
dir = 0;
period = MAX_PERIOD;
}
} else {
period /= 2;

if (period < MIN_PERIOD) {
dir = 1;
period = MIN_PERIOD;
}
}

nano_timer_start(&timer, SLEEPTICKS);
nano_timer_test(&timer, TICKS_UNLIMITED);
}
}

I have found another way to do what I want so no rush. Just wanted to state that it's not working.

Kind regards
Anders Dam Kofoed


--
Maciek Borzecki