Date   

Re: [Zephyr-devel] Buggy PWM driver for nRF52

Vikrant More <vikrant8051@...>
 

Hi Felipe,

Thanks for you support.
I also used this style to take advantage of SoC built-in PWM module.

But was not able to generate PWM with different pulse_width using same instance.
Now it is possible.

We have to enable
NRF_PWM0->ENABLE = 1;

at last to achieve that.


Thanks once again !!


 

On Thu, Feb 8, 2018 at 4:47 PM, Felipe Neves <ryukokki.felipe@...> wrote:
Hello guys.

@Vikrant you are right, the current implementation of nrf pwm's driver uses a software based PWM combined with the PPI.

Here in my work we are using zephyr built for nordic target with pwm, we don't implemented the driver on zepyr's model because we haven't time to validate and integrate it.

But here is a working code to setup the PWM at 1KHz clocked by 8MHz and a set duty function, I'm planning to move this to a PR later but if anyone wants to submit it, please feel free,

take a look:


/* pwm output pin */
#define PWM_OUT_PIN		(0 | 31)

/* pwm frequency and clk in Hz */
#define PWM_FREQUENCY			1000
#define PWM_CLK					8000000
#define PWM_TOP_VALUE_FIX		(PWM_CLK / PWM_FREQUENCY)
#define PWM_MAX_DUTY			0.30f /* 30 % */
#define PWM_MIN_DUTY			0.05   /* 5% */
#define PWM_PERCENT_RESOLUTION	0.0125 /* % */

/* polarity to be added on pwm sequencer */
#define PWM_POLARITY_OFFSET		(1 << 15)

/** private variables */
static uint16_t nrf_pwm_sequence[4] = {4096 + PWM_POLARITY_OFFSET , 0 + PWM_POLARITY_OFFSET, 0 + PWM_POLARITY_OFFSET, 0 + PWM_POLARITY_OFFSET};

/**
 * temp_pwm_init()
 *
 * @brief inits the pwm controller and route it to the heater
 * @param
 * @return
 */
static void temp_pwm_init(void)
{
	NRF_PWM0->PSEL.OUT[0] = PWM_OUT_PIN;

	/* pwm in upmode */
	NRF_PWM0->MODE = 0;

	/* sets pwm count top to be at 1 KHz  and decode pwm in common mode*/
	NRF_PWM0->COUNTERTOP = PWM_CLK / PWM_FREQUENCY;
	NRF_PWM0->DECODER =  0x00000002;
	NRF_PWM0->LOOP = 0;
	NRF_PWM0->SEQ[0].REFRESH = 0;
	NRF_PWM0->SEQ[0].ENDDELAY = 0;

	/* select clock source prescaler */
	NRF_PWM0->PRESCALER = 0x00000001;

	/* enables the PWM */
	NRF_PWM0->SEQ[0].PTR  = ((uint32_t)nrf_pwm_sequence);
	NRF_PWM0->SEQ[0].CNT  = sizeof(nrf_pwm_sequence) / sizeof(uint16_t);
	NRF_PWM0->ENABLE = 1;

	/* trigger it! */
	NRF_PWM0->TASKS_SEQSTART[0] = 1;
}

/**
 * temp_pwm_set_val()
 *
 * @brief set the pwm with a new duty cicle
 * @param
 * @return
 */
static void temp_pwm_set_val(float required_energy)
{

#ifndef TEMP_CLOSED_LOOP
	/* saturate the energy expected */
	if(required_energy < TEMP_MAINTENANCE_ENERGY)
		required_energy = TEMP_MAINTENANCE_ENERGY;

	if(required_energy > TEMP_MAXIMUM_ENERGY_AVAILABLE)
		required_energy = TEMP_MAXIMUM_ENERGY_AVAILABLE;

#else
	/* saturate the energy required to the bound values, note in closed loop
	 * we can increase the pwm output to the maximum during a cycle
	 */
	if(required_energy < TEMP_MAINTENANCE_ENERGY)
		required_energy = TEMP_MAINTENANCE_ENERGY;

	if(required_energy > TEMP_MAXIMUM_ENERGY_EXCURTION)
		required_energy = TEMP_MAXIMUM_ENERGY_EXCURTION;

#endif

	/* obtains the duty cicle  and sums it up with polarity offset */
	uint16_t duty = (uint16_t)((required_energy / TEMP_MAXIMUM_ENERGY_EXCURTION) * (float)PWM_TOP_VALUE_FIX);
	duty |= PWM_POLARITY_OFFSET;


	/* update the duty cicle */
	nrf_pwm_sequence[0] = duty;
	nrf_pwm_sequence[1] = duty;
	nrf_pwm_sequence[2] = duty;
	nrf_pwm_sequence[3] = duty;

	NRF_PWM0->TASKS_SEQSTART[0] = 1;
}


The nrf_pwm_sequence variable is a kind of PWM descriptor which holds the value of duty cycle concatenated with the polarity bit,
the 4096 value means near 50% of duty cicle on channel 0, please note each pwm instance can be mapped to any pin of
nordic chip and each instance has up to 4 channels.

Please let me know if this was helpful.

best

Felipe


2018-02-08 7:50 GMT-02:00 Vikrant More <vikrant8051@...>:
I'm not able to understand what you are saying.

Is that means Zephyr PWM (fade_led example) is using software to generate PWM instead of separate dedicated
SoC's internal PWM module ?

On Thu, Feb 8, 2018 at 3:01 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Your main.c uses pwm_nrf5_sw.c driver which has conflict with BT features on nRF52840...

I do not see use of NRF_PWM0 in you main.c, of course, yes your code in the devzone does, hope you get some help there and can contribute a Zephyr driver.

I am not familiar with NRF_PWM0, hence not much help for you.

We are in the process of contributing driver based on nRFx external interfaces, you may just have to wait for it.

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 10:21 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>
Cc: zephyr-devel@...ct.org; zephyr-users@...ct.org


Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

>> Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

Means ??

I am using h/w PWM only !! Have you looked my main.c ?

Instead I used direct register access method to set PWM on

P0.13(LED_1) & P0.14(LED2)

Here too, I failed to create two PWM with different pulse_width using single instance i.e. PWM0

So I used PWM1 for LED2.

Nordic Datasheet is also not clear about it.

So I open new ticket on Nordic #devzone forum,

https://devzone.nordicsemi.com/f/nordic-q-a/30328/nrf52840-create-2-pwms-with-different-pulse-width-using-single-instance-by-direct-register-access

 

On Thu, Feb 8, 2018 at 2:32 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

As i said, there is possible overlap of PPIs with BT Controller. PPI channel 16 and 17 overlap with Code PHY feature in nRF52840.

 

I will try to send a PR wherein you could (correctly) disable Coded PHY support in nRF52840 so as to have PPI Channels from 14 to 19 available for 3 LEDs.

 

Until then, use 3 LEDs and expect 2nd LED to malfunction.

 

Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

 

Regards,

Vinayak

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 9:31 AM


To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I also able to generate & vary PWM as you did.

Problem arises when we create two channels from PWM0.

One channel -> LED1

Second Channel -> LED2

When I vary LED1 pulse width, sometimes it affects intensity of LED2

Similarly, when I vary LED2 pulse width it affects intensity of LED1

For details I've attached my main.c. Please have a look.

Use nRF connect to send data

send 0100 (ascii string) -> it is for LED1

send 1100 (ascii string) -> it is for LED2

And you will find what I'm saying.

 

 

On Thu, Feb 8, 2018 at 1:37 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

I have run the upstream fade_led sample on nrf52840-PDK, I see no regression, the brightness changes every second (up and then down so on).

I advice you to debug your implementation as I have no visibility to your design.

 

Regards,

Vinayak

 

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 8:55 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>

Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I'm working nRF52840-PDK board.

 

On Thu, Feb 8, 2018 at 1:21 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@...hyrproject.org [mailto:zephyr-devel-bounces@lists.zephyrproject.org] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@...ct.org; zephyr-devel@...ct.org; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 

 

 

 



_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--
Felipe S. Neves 
Embedded software & systems engineer
Skype: fneves1989
+55 11 96610 – 0855 


Re: [Zephyr-devel] Buggy PWM driver for nRF52

Felipe Neves
 

Hello guys.

@Vikrant you are right, the current implementation of nrf pwm's driver uses a software based PWM combined with the PPI.

Here in my work we are using zephyr built for nordic target with pwm, we don't implemented the driver on zepyr's model because we haven't time to validate and integrate it.

But here is a working code to setup the PWM at 1KHz clocked by 8MHz and a set duty function, I'm planning to move this to a PR later but if anyone wants to submit it, please feel free,

take a look:


/* pwm output pin */
#define PWM_OUT_PIN		(0 | 31)

/* pwm frequency and clk in Hz */
#define PWM_FREQUENCY			1000
#define PWM_CLK					8000000
#define PWM_TOP_VALUE_FIX		(PWM_CLK / PWM_FREQUENCY)
#define PWM_MAX_DUTY			0.30f /* 30 % */
#define PWM_MIN_DUTY			0.05   /* 5% */
#define PWM_PERCENT_RESOLUTION	0.0125 /* % */

/* polarity to be added on pwm sequencer */
#define PWM_POLARITY_OFFSET		(1 << 15)

/** private variables */
static uint16_t nrf_pwm_sequence[4] = {4096 + PWM_POLARITY_OFFSET , 0 + PWM_POLARITY_OFFSET, 0 + PWM_POLARITY_OFFSET, 0 + PWM_POLARITY_OFFSET};

/**
 * temp_pwm_init()
 *
 * @brief inits the pwm controller and route it to the heater
 * @param
 * @return
 */
static void temp_pwm_init(void)
{
	NRF_PWM0->PSEL.OUT[0] = PWM_OUT_PIN;

	/* pwm in upmode */
	NRF_PWM0->MODE = 0;

	/* sets pwm count top to be at 1 KHz  and decode pwm in common mode*/
	NRF_PWM0->COUNTERTOP = PWM_CLK / PWM_FREQUENCY;
	NRF_PWM0->DECODER =  0x00000002;
	NRF_PWM0->LOOP = 0;
	NRF_PWM0->SEQ[0].REFRESH = 0;
	NRF_PWM0->SEQ[0].ENDDELAY = 0;

	/* select clock source prescaler */
	NRF_PWM0->PRESCALER = 0x00000001;

	/* enables the PWM */
	NRF_PWM0->SEQ[0].PTR  = ((uint32_t)nrf_pwm_sequence);
	NRF_PWM0->SEQ[0].CNT  = sizeof(nrf_pwm_sequence) / sizeof(uint16_t);
	NRF_PWM0->ENABLE = 1;

	/* trigger it! */
	NRF_PWM0->TASKS_SEQSTART[0] = 1;
}

/**
 * temp_pwm_set_val()
 *
 * @brief set the pwm with a new duty cicle
 * @param
 * @return
 */
static void temp_pwm_set_val(float required_energy)
{

#ifndef TEMP_CLOSED_LOOP
	/* saturate the energy expected */
	if(required_energy < TEMP_MAINTENANCE_ENERGY)
		required_energy = TEMP_MAINTENANCE_ENERGY;

	if(required_energy > TEMP_MAXIMUM_ENERGY_AVAILABLE)
		required_energy = TEMP_MAXIMUM_ENERGY_AVAILABLE;

#else
	/* saturate the energy required to the bound values, note in closed loop
	 * we can increase the pwm output to the maximum during a cycle
	 */
	if(required_energy < TEMP_MAINTENANCE_ENERGY)
		required_energy = TEMP_MAINTENANCE_ENERGY;

	if(required_energy > TEMP_MAXIMUM_ENERGY_EXCURTION)
		required_energy = TEMP_MAXIMUM_ENERGY_EXCURTION;

#endif

	/* obtains the duty cicle  and sums it up with polarity offset */
	uint16_t duty = (uint16_t)((required_energy / TEMP_MAXIMUM_ENERGY_EXCURTION) * (float)PWM_TOP_VALUE_FIX);
	duty |= PWM_POLARITY_OFFSET;


	/* update the duty cicle */
	nrf_pwm_sequence[0] = duty;
	nrf_pwm_sequence[1] = duty;
	nrf_pwm_sequence[2] = duty;
	nrf_pwm_sequence[3] = duty;

	NRF_PWM0->TASKS_SEQSTART[0] = 1;
}


The nrf_pwm_sequence variable is a kind of PWM descriptor which holds the value of duty cycle concatenated with the polarity bit,
the 4096 value means near 50% of duty cicle on channel 0, please note each pwm instance can be mapped to any pin of
nordic chip and each instance has up to 4 channels.

Please let me know if this was helpful.

best

Felipe


2018-02-08 7:50 GMT-02:00 Vikrant More <vikrant8051@...>:

I'm not able to understand what you are saying.

Is that means Zephyr PWM (fade_led example) is using software to generate PWM instead of separate dedicated
SoC's internal PWM module ?

On Thu, Feb 8, 2018 at 3:01 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Your main.c uses pwm_nrf5_sw.c driver which has conflict with BT features on nRF52840...

I do not see use of NRF_PWM0 in you main.c, of course, yes your code in the devzone does, hope you get some help there and can contribute a Zephyr driver.

I am not familiar with NRF_PWM0, hence not much help for you.

We are in the process of contributing driver based on nRFx external interfaces, you may just have to wait for it.

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 10:21 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>
Cc: zephyr-devel@...ct.org; zephyr-users@...ct.org


Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

>> Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

Means ??

I am using h/w PWM only !! Have you looked my main.c ?

Instead I used direct register access method to set PWM on

P0.13(LED_1) & P0.14(LED2)

Here too, I failed to create two PWM with different pulse_width using single instance i.e. PWM0

So I used PWM1 for LED2.

Nordic Datasheet is also not clear about it.

So I open new ticket on Nordic #devzone forum,

https://devzone.nordicsemi.com/f/nordic-q-a/30328/nrf52840-create-2-pwms-with-different-pulse-width-using-single-instance-by-direct-register-access

 

On Thu, Feb 8, 2018 at 2:32 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

As i said, there is possible overlap of PPIs with BT Controller. PPI channel 16 and 17 overlap with Code PHY feature in nRF52840.

 

I will try to send a PR wherein you could (correctly) disable Coded PHY support in nRF52840 so as to have PPI Channels from 14 to 19 available for 3 LEDs.

 

Until then, use 3 LEDs and expect 2nd LED to malfunction.

 

Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

 

Regards,

Vinayak

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 9:31 AM


To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I also able to generate & vary PWM as you did.

Problem arises when we create two channels from PWM0.

One channel -> LED1

Second Channel -> LED2

When I vary LED1 pulse width, sometimes it affects intensity of LED2

Similarly, when I vary LED2 pulse width it affects intensity of LED1

For details I've attached my main.c. Please have a look.

Use nRF connect to send data

send 0100 (ascii string) -> it is for LED1

send 1100 (ascii string) -> it is for LED2

And you will find what I'm saying.

 

 

On Thu, Feb 8, 2018 at 1:37 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

I have run the upstream fade_led sample on nrf52840-PDK, I see no regression, the brightness changes every second (up and then down so on).

I advice you to debug your implementation as I have no visibility to your design.

 

Regards,

Vinayak

 

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 8:55 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>

Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I'm working nRF52840-PDK board.

 

On Thu, Feb 8, 2018 at 1:21 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@...hyrproject.org [mailto:zephyr-devel-bounces@lists.zephyrproject.org] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@...ct.org; zephyr-devel@...ct.org; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 

 

 

 



_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--
Felipe S. Neves 
Embedded software & systems engineer
Skype: fneves1989
+55 11 96610 – 0855 


Re: [Zephyr-devel] Buggy PWM driver for nRF52

Vikrant More <vikrant8051@...>
 

I'm not able to understand what you are saying.

Is that means Zephyr PWM (fade_led example) is using software to generate PWM instead of separate dedicated
SoC's internal PWM module ?

On Thu, Feb 8, 2018 at 3:01 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Your main.c uses pwm_nrf5_sw.c driver which has conflict with BT features on nRF52840...

I do not see use of NRF_PWM0 in you main.c, of course, yes your code in the devzone does, hope you get some help there and can contribute a Zephyr driver.

I am not familiar with NRF_PWM0, hence not much help for you.

We are in the process of contributing driver based on nRFx external interfaces, you may just have to wait for it.

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 10:21 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>
Cc: zephyr-devel@lists.zephyrproject.org; zephyr-users@lists.zephyrproject.org


Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

>> Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

Means ??

I am using h/w PWM only !! Have you looked my main.c ?

Instead I used direct register access method to set PWM on

P0.13(LED_1) & P0.14(LED2)

Here too, I failed to create two PWM with different pulse_width using single instance i.e. PWM0

So I used PWM1 for LED2.

Nordic Datasheet is also not clear about it.

So I open new ticket on Nordic #devzone forum,

https://devzone.nordicsemi.com/f/nordic-q-a/30328/nrf52840-create-2-pwms-with-different-pulse-width-using-single-instance-by-direct-register-access

 

On Thu, Feb 8, 2018 at 2:32 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

As i said, there is possible overlap of PPIs with BT Controller. PPI channel 16 and 17 overlap with Code PHY feature in nRF52840.

 

I will try to send a PR wherein you could (correctly) disable Coded PHY support in nRF52840 so as to have PPI Channels from 14 to 19 available for 3 LEDs.

 

Until then, use 3 LEDs and expect 2nd LED to malfunction.

 

Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

 

Regards,

Vinayak

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 9:31 AM


To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I also able to generate & vary PWM as you did.

Problem arises when we create two channels from PWM0.

One channel -> LED1

Second Channel -> LED2

When I vary LED1 pulse width, sometimes it affects intensity of LED2

Similarly, when I vary LED2 pulse width it affects intensity of LED1

For details I've attached my main.c. Please have a look.

Use nRF connect to send data

send 0100 (ascii string) -> it is for LED1

send 1100 (ascii string) -> it is for LED2

And you will find what I'm saying.

 

 

On Thu, Feb 8, 2018 at 1:37 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

I have run the upstream fade_led sample on nrf52840-PDK, I see no regression, the brightness changes every second (up and then down so on).

I advice you to debug your implementation as I have no visibility to your design.

 

Regards,

Vinayak

 

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 8:55 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>

Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I'm working nRF52840-PDK board.

 

On Thu, Feb 8, 2018 at 1:21 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@lists.zephyrproject.org [mailto:zephyr-devel-bounces@lists.zephyrproject.org] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@lists.zephyrproject.org; zephyr-devel@lists.zephyrproject.org; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 

 

 

 



Re: [Zephyr-devel] Buggy PWM driver for nRF52

Chettimada, Vinayak Kariappa
 

Your main.c uses pwm_nrf5_sw.c driver which has conflict with BT features on nRF52840...

I do not see use of NRF_PWM0 in you main.c, of course, yes your code in the devzone does, hope you get some help there and can contribute a Zephyr driver.

I am not familiar with NRF_PWM0, hence not much help for you.

We are in the process of contributing driver based on nRFx external interfaces, you may just have to wait for it.

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 10:21 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...>
Cc: zephyr-devel@...; zephyr-users@...
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

>> Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

Means ??

I am using h/w PWM only !! Have you looked my main.c ?

Instead I used direct register access method to set PWM on

P0.13(LED_1) & P0.14(LED2)

Here too, I failed to create two PWM with different pulse_width using single instance i.e. PWM0

So I used PWM1 for LED2.

Nordic Datasheet is also not clear about it.

So I open new ticket on Nordic #devzone forum,

https://devzone.nordicsemi.com/f/nordic-q-a/30328/nrf52840-create-2-pwms-with-different-pulse-width-using-single-instance-by-direct-register-access

 

On Thu, Feb 8, 2018 at 2:32 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Hi Vikrant,

 

As i said, there is possible overlap of PPIs with BT Controller. PPI channel 16 and 17 overlap with Code PHY feature in nRF52840.

 

I will try to send a PR wherein you could (correctly) disable Coded PHY support in nRF52840 so as to have PPI Channels from 14 to 19 available for 3 LEDs.

 

Until then, use 3 LEDs and expect 2nd LED to malfunction.

 

Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

 

Regards,

Vinayak

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 9:31 AM


To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I also able to generate & vary PWM as you did.

Problem arises when we create two channels from PWM0.

One channel -> LED1

Second Channel -> LED2

When I vary LED1 pulse width, sometimes it affects intensity of LED2

Similarly, when I vary LED2 pulse width it affects intensity of LED1

For details I've attached my main.c. Please have a look.

Use nRF connect to send data

send 0100 (ascii string) -> it is for LED1

send 1100 (ascii string) -> it is for LED2

And you will find what I'm saying.

 

 

On Thu, Feb 8, 2018 at 1:37 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Hi Vikrant,

 

I have run the upstream fade_led sample on nrf52840-PDK, I see no regression, the brightness changes every second (up and then down so on).

I advice you to debug your implementation as I have no visibility to your design.

 

Regards,

Vinayak

 

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 8:55 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...>

Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I'm working nRF52840-PDK board.

 

On Thu, Feb 8, 2018 at 1:21 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@...; zephyr-devel@...; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 

 

 

 


Re: [Zephyr-devel] Buggy PWM driver for nRF52

Vikrant More <vikrant8051@...>
 

>> Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

Means ??

I am using h/w PWM only !! Have you looked my main.c ?

Instead I used direct register access method to set PWM on
P0.13(LED_1) & P0.14(LED2)

Here too, I failed to create two PWM with different pulse_width using single instance i.e. PWM0

So I used PWM1 for LED2.

Nordic Datasheet is also not clear about it.

So I open new ticket on Nordic #devzone forum,

https://devzone.nordicsemi.com/f/nordic-q-a/30328/nrf52840-create-2-pwms-with-different-pulse-width-using-single-instance-by-direct-register-access


On Thu, Feb 8, 2018 at 2:32 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Hi Vikrant,

 

As i said, there is possible overlap of PPIs with BT Controller. PPI channel 16 and 17 overlap with Code PHY feature in nRF52840.

 

I will try to send a PR wherein you could (correctly) disable Coded PHY support in nRF52840 so as to have PPI Channels from 14 to 19 available for 3 LEDs.

 

Until then, use 3 LEDs and expect 2nd LED to malfunction.

 

Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

 

Regards,

Vinayak

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 9:31 AM


To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I also able to generate & vary PWM as you did.

Problem arises when we create two channels from PWM0.

One channel -> LED1

Second Channel -> LED2

When I vary LED1 pulse width, sometimes it affects intensity of LED2

Similarly, when I vary LED2 pulse width it affects intensity of LED1

For details I've attached my main.c. Please have a look.

Use nRF connect to send data

send 0100 (ascii string) -> it is for LED1

send 1100 (ascii string) -> it is for LED2

And you will find what I'm saying.

 

 

On Thu, Feb 8, 2018 at 1:37 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

I have run the upstream fade_led sample on nrf52840-PDK, I see no regression, the brightness changes every second (up and then down so on).

I advice you to debug your implementation as I have no visibility to your design.

 

Regards,

Vinayak

 

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 8:55 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>

Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I'm working nRF52840-PDK board.

 

On Thu, Feb 8, 2018 at 1:21 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@lists.zephyrproject.org [mailto:zephyr-devel-bounces@lists.zephyrproject.org] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@lists.zephyrproject.org; zephyr-devel@lists.zephyrproject.org; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 

 

 



Re: [Zephyr-devel] Buggy PWM driver for nRF52

Chettimada, Vinayak Kariappa
 

Hi Vikrant,

 

As i said, there is possible overlap of PPIs with BT Controller. PPI channel 16 and 17 overlap with Code PHY feature in nRF52840.

 

I will try to send a PR wherein you could (correctly) disable Coded PHY support in nRF52840 so as to have PPI Channels from 14 to 19 available for 3 LEDs.

 

Until then, use 3 LEDs and expect 2nd LED to malfunction.

 

Again, I will like to iterate that for nRF52840, h/w PWM driver has to be used, feel free to contribute (isn’t it fun to develop than test ;) )

 

Regards,

Vinayak

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 9:31 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I also able to generate & vary PWM as you did.

Problem arises when we create two channels from PWM0.

One channel -> LED1

Second Channel -> LED2

When I vary LED1 pulse width, sometimes it affects intensity of LED2

Similarly, when I vary LED2 pulse width it affects intensity of LED1

For details I've attached my main.c. Please have a look.

Use nRF connect to send data

send 0100 (ascii string) -> it is for LED1

send 1100 (ascii string) -> it is for LED2

And you will find what I'm saying.

 

 

On Thu, Feb 8, 2018 at 1:37 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Hi Vikrant,

 

I have run the upstream fade_led sample on nrf52840-PDK, I see no regression, the brightness changes every second (up and then down so on).

I advice you to debug your implementation as I have no visibility to your design.

 

Regards,

Vinayak

 

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 8:55 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...>

Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I'm working nRF52840-PDK board.

 

On Thu, Feb 8, 2018 at 1:21 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@...; zephyr-devel@...; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 

 

 


Re: [Zephyr-devel] Buggy PWM driver for nRF52

ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi Vinayak,

fade_led sample runs as expected. We are trying to generate PWM on two channels. Adding 

pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0,PERIOD, pulse_width);
pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1,PERIOD, pulse_width);

Creates unexpected behavior. 



--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Thu, Feb 8, 2018 at 1:37 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Hi Vikrant,

 

I have run the upstream fade_led sample on nrf52840-PDK, I see no regression, the brightness changes every second (up and then down so on).

I advice you to debug your implementation as I have no visibility to your design.

 

Regards,

Vinayak

 

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 8:55 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I'm working nRF52840-PDK board.

 

On Thu, Feb 8, 2018 at 1:21 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@lists.zephyrproject.org [mailto:zephyr-devel-bounces@lists.zephyrproject.org] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@lists.zephyrproject.org; zephyr-devel@lists.zephyrproject.org; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 

 


_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users



Re: [Zephyr-devel] Buggy PWM driver for nRF52

Chettimada, Vinayak Kariappa
 

Hi Vikrant,

 

I have run the upstream fade_led sample on nrf52840-PDK, I see no regression, the brightness changes every second (up and then down so on).

I advice you to debug your implementation as I have no visibility to your design.

 

Regards,

Vinayak

 

 

From: Vikrant More [mailto:vikrant8051@...]
Sent: Thursday, February 08, 2018 8:55 AM
To: Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Vinayak,

I'm working nRF52840-PDK board.

 

On Thu, Feb 8, 2018 at 1:21 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@...> wrote:

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@...; zephyr-devel@...; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 

 


Re: [Zephyr-devel] Buggy PWM driver for nRF52

Chettimada, Vinayak Kariappa
 

Hi Vikrant,

 

Please try the PWM without the BT Controller included. There could be some PWM regression due to changes in controller implementation.

That said the nrf5_sw  driver is software variant designed for older nRF51 SoCs. For newer nRF52x series h/w PWM’s should be used.

 

Nrf5_sw will work provided careful mitigation of used PPI and timers between the driver and BT controller use.

 

Which SoC are you using?

 

Regards,

Vinayak

 

From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of Vikrant More
Sent: Thursday, February 08, 2018 5:04 AM
To: Marti Bolivar <marti@...>
Cc: zephyr-users@...; zephyr-devel@...; Felipe Neves <ryukokki.felipe@...>
Subject: Re: [Zephyr-devel] [Zephyr-users] Buggy PWM driver for nRF52

 

Hi Marti,

>>Are you using the latest master?

Yes

 

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:

Hi Vikrant,

 

Are you using the latest master?

 

Three improvements to nRF PWM went in fairly recently:

 

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active

ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default

cec073c35 pwm: nrf5_sw: add support for SYS_LOG

 

Thanks,

Marti

 

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:

I took reference of $zephy/samples/samples/fade_led project

 

& add following parameters in my prj.conf

 

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4
 
Could you please inform me, what I should do besides this ??
 
Thank You !!

 

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?

Best

Felipe

 

 

2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }

And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.

I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--

Felipe S. Neves 

Embedded software & systems engineer

Skype: fneves1989


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users

 

 


Re: Buggy PWM driver for nRF52

Vikrant More <vikrant8051@...>
 

Hi Marti,

>>Are you using the latest master?
Yes

On Thu, Feb 8, 2018 at 1:23 AM, Marti Bolivar <marti@...> wrote:
Hi Vikrant,

Are you using the latest master?

Three improvements to nRF PWM went in fairly recently:

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active
ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default
cec073c35 pwm: nrf5_sw: add support for SYS_LOG

Thanks,
Marti

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:
I took reference of $zephy/samples/samples/fade_led project

& add following parameters in my prj.conf

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4

Could you please inform me, what I should do besides this ??

Thank You !!

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:
Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?


Best

Felipe


2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:
Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }


And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.
I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?

_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--
Felipe S. Neves 
Embedded software & systems engineer
Skype: fneves1989

_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




Re: Buggy PWM driver for nRF52

Marti Bolivar
 

Hi Vikrant,

Are you using the latest master?

Three improvements to nRF PWM went in fairly recently:

3f1dbfda1 pwm: nrf5_sw: don't disable timer if another channel is still active
ab399a1cf pwm: nrf5_sw: do not use 'inversed' polarity by default
cec073c35 pwm: nrf5_sw: add support for SYS_LOG

Thanks,
Marti

On Wed, Feb 7, 2018 at 1:59 PM, Vikrant More <vikrant8051@...> wrote:
I took reference of $zephy/samples/samples/fade_led project

& add following parameters in my prj.conf

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4

Could you please inform me, what I should do besides this ??

Thank You !!

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:
Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?


Best

Felipe


2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:
Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }


And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.
I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?

_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--
Felipe S. Neves 
Embedded software & systems engineer
Skype: fneves1989

_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users



Re: Buggy PWM driver for nRF52

Vikrant More <vikrant8051@...>
 

I took reference of $zephy/samples/samples/fade_led project

& add following parameters in my prj.conf

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_PWM=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_PWM_LEVEL=4

Could you please inform me, what I should do besides this ??

Thank You !!

On Feb 7, 2018 11:36 PM, "Felipe Neves" <ryukokki.felipe@...> wrote:
Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?


Best

Felipe


2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:
Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }


And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.
I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?

_______________________________________________
Zephyr-users mailing list
Zephyr-users@...ct.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--
Felipe S. Neves 
Embedded software & systems engineer
Skype: fneves1989
+55 11 96610 – 0855 


Re: [Zephyr-devel] Power Configuration of nrf52840

Vinayak Kariappa
 

Hi Ashish,

UICR is Flash, you need to do something similar to in soc.c done for reset pin config. Or use nrfjprog to write values to UICR


On 7 Feb 2018, at 12:04, "ashish.shukla@..." <ashish.shukla@...> wrote:

Hi,

Yes, I'm working in high voltage mode.  VDDH = 3.6V

Then, I added following lines

NRF_POWER->DCDCEN0 = 0x01;  // Enabling DC/DC for stage REG0
NRF_POWER->DCDCEN = 0x01;   // Enabling DC/DC for stage REG1

Again, as you suggested

NRF_UICR->EXTSUPPLY = 0x01; 
NRF_UICR->REGOUT0 = 0x05;

After adding these lines at starting of main() function, It still measures 1.8V.


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Wed, Feb 7, 2018 at 4:16 PM, Puzdrowski, Andrzej <Andrzej.Puzdrowski@...> wrote:

Hi

So you must have supplied nRF52840 from VDDH pin – so it power regulator circuit works in high voltage mode.

 

Then internal regulator generate the GPIO output voltage:

You need to set UICR->REGOUT0 properly, 5 is proper value for select 3.3 V

 

For more info see nRF52840 OPS, especjali POWER chapter

 

Andrzej

 

From: zephyr-devel-bounces@lists.zephyrproject.org [mailto:zephyr-devel-bounces@lists.zephyrproject.org] On Behalf Of ashish.shukla@...
Sent: Wednesday, February 07, 2018 8:22 AM
To: zephyr-devel@lists.zephyrproject.org; zephyr-users@lists.zephyrproject.org
Subject: [Zephyr-devel] Power Configuration of nrf52840

 

Hello everyone !!!

I'm working with custom PCB of nrf52840. I need to set VDD voltage which is also GPIO high level voltage equals to 3.3V, otherwise it's 1.8V by default.


How can I configure this?

or

How can I access registers of nrf52840 in zephyr architecture?    

 

 

--

Warm regards,
Ashish Shukla

Jr. Embedded Engineer

Research & Development

 

Please consider the environment before printing this e-mail or its attachments.

 

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi

 


_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users


Re: Buggy PWM driver for nRF52

Felipe Neves
 

Hi Vikrant,

Did you configure what pins are associated to pwm duty_cycles on the menuconfig?


Best

Felipe


2018-02-07 10:15 GMT-02:00 Vikrant More <vikrant8051@...>:

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }


And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.
I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?

_______________________________________________
Zephyr-users mailing list
Zephyr-users@lists.zephyrproject.org
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users




--
Felipe S. Neves 
Embedded software & systems engineer
Skype: fneves1989
+55 11 96610 – 0855 


Buggy PWM driver for nRF52

Vikrant More <vikrant8051@...>
 

Hello World !!

I've added following lines in my project main ()

    pwm_dev = device_get_binding(PWM_DRIVER);

    if (!pwm_dev)
    {
        printk("Cannot find %s!\n", PWM_DRIVER);
        return;
    }

   
    while(1)
    {
   
        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL0, PERIOD, pulse_width0))
        {
            printk("pwm pin set fails\n");
        }

        if(pwm_pin_set_usec(pwm_dev, PWM_CHANNEL1, PERIOD, pulse_width1))
        {
            printk("pwm pin set fails\n");
        }

        k_sleep(100);
    }


And using bluetooth updating value of pulse_width0 & pulse_width1. Those two are defined as global variables.

pulse_width0 --> LED_1 on nrf52840_PDK
pulse_width1 --> LED_2 on nrf52840_PDK

I'm able to update value of both these variables using Bluetooth.
I used printk to check it. My logic is perfect.

But if I vary pulse_width0 then it affects intensity of LED2
& if I vary pulse_width1 then it affects intensity of LED1.

Why ? Is anyone found this BUG ?


Re: [Zephyr-devel] Power Configuration of nrf52840

ashish.shukla@corvi.com <ashish.shukla@...>
 

Hi,

Yes, I'm working in high voltage mode.  VDDH = 3.6V

Then, I added following lines

NRF_POWER->DCDCEN0 = 0x01;  // Enabling DC/DC for stage REG0
NRF_POWER->DCDCEN = 0x01;   // Enabling DC/DC for stage REG1

Again, as you suggested

NRF_UICR->EXTSUPPLY = 0x01; 
NRF_UICR->REGOUT0 = 0x05;

After adding these lines at starting of main() function, It still measures 1.8V.


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


On Wed, Feb 7, 2018 at 4:16 PM, Puzdrowski, Andrzej <Andrzej.Puzdrowski@...> wrote:

Hi

So you must have supplied nRF52840 from VDDH pin – so it power regulator circuit works in high voltage mode.

 

Then internal regulator generate the GPIO output voltage:

You need to set UICR->REGOUT0 properly, 5 is proper value for select 3.3 V

 

For more info see nRF52840 OPS, especjali POWER chapter

 

Andrzej

 

From: zephyr-devel-bounces@lists.zephyrproject.org [mailto:zephyr-devel-bounces@lists.zephyrproject.org] On Behalf Of ashish.shukla@...
Sent: Wednesday, February 07, 2018 8:22 AM
To: zephyr-devel@lists.zephyrproject.org; zephyr-users@lists.zephyrproject.org
Subject: [Zephyr-devel] Power Configuration of nrf52840

 

Hello everyone !!!

I'm working with custom PCB of nrf52840. I need to set VDD voltage which is also GPIO high level voltage equals to 3.3V, otherwise it's 1.8V by default.


How can I configure this?

or

How can I access registers of nrf52840 in zephyr architecture?    

 

 

--

Warm regards,
Ashish Shukla

Jr. Embedded Engineer

Research & Development

 

Please consider the environment before printing this e-mail or its attachments.

 

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi

 



Re: [Zephyr-devel] Power Configuration of nrf52840

Puzdrowski, Andrzej <Andrzej.Puzdrowski@...>
 

Hi

So you must have supplied nRF52840 from VDDH pin – so it power regulator circuit works in high voltage mode.

 

Then internal regulator generate the GPIO output voltage:

You need to set UICR->REGOUT0 properly, 5 is proper value for select 3.3 V

 

For more info see nRF52840 OPS, especjali POWER chapter

 

Andrzej

 

From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of ashish.shukla@...
Sent: Wednesday, February 07, 2018 8:22 AM
To: zephyr-devel@...; zephyr-users@...
Subject: [Zephyr-devel] Power Configuration of nrf52840

 

Hello everyone !!!

I'm working with custom PCB of nrf52840. I need to set VDD voltage which is also GPIO high level voltage equals to 3.3V, otherwise it's 1.8V by default.


How can I configure this?

or

How can I access registers of nrf52840 in zephyr architecture?    

 

 

--

Warm regards,
Ashish Shukla

Jr. Embedded Engineer

Research & Development

 

Please consider the environment before printing this e-mail or its attachments.

 

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi

 


Power Configuration of nrf52840

ashish.shukla@corvi.com <ashish.shukla@...>
 

Hello everyone !!!

I'm working with custom PCB of nrf52840. I need to set VDD voltage which is also GPIO high level voltage equals to 3.3V, otherwise it's 1.8V by default.

How can I configure this?

or

How can I access registers of nrf52840 in zephyr architecture?    


--
Warm regards,
Ashish Shukla
Jr. Embedded Engineer
Research & Development


Please consider the environment before printing this e-mail or its attachments.

Disclaimer: The information contained herein (including any accompanying documents) is confidential and is intended solely for the addressee(s). If you have erroneously received this message, please immediately delete it and notify the sender. Also, if you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this message or any accompanying document is strictly prohibited and is unlawful. The organization is not responsible for any damage caused by a virus or alteration of the e-mail by a third party or otherwise. The contents of this message may not necessarily represent the views or policies of Corvi


Re: 1-32khz sensor-sampling loop

Michael Hope
 

Hi Nathan.  I'm fairly new to Zephyr, but if you're looking for hard real time-ish at 32 kHz then I'd talk straight to the hardware.

For example, say I needed to read an ADC channel at 32 kHz on the ATSAMD21.  I'd use the Zephyr drivers to initialise the ADC and DMA units and then do custom iniitalisation that:

- Sets up a 32 kHz hardware timer
- Uses the SAM0 event system to hook the timer into the ADC trigger
- Uses the SAM0 DMA unit to read the ADC and write to memory when the ADC conversion complete event triggers

The DMA can work in ping-pong mode and fire an interrupt when the buffer is half full.  This can then set a semaphore and wake up your task.

Hope that helps,

-- Michael


On Fri, 2 Feb 2018 at 17:36 Nathan T <nathan@...> wrote:
hi all,

i'd like to sample a sensor (actually several sensors) in precise intervals at speeds up to 32khz.

it seems timer and sleep functions only have millisecond resolution and I cannot busy wait.

anyone have suggestions on the best way to go about this? 

best,
nathan
_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users


Re: Running ZTest for custom drivers on Boards.

Nashif, Anas
 

Hi,

That is correct, a test is just another application.

Try a test that is known to work, for example a kernel test and see if you get the output.

 

Anas

 

From: dhananjay gj [mailto:dhguja@...]
Sent: Tuesday, February 6, 2018 9:54 AM
To: Nashif, Anas <anas.nashif@...>
Cc: zephyr-users@...
Subject: Re: [Zephyr-users] Running ZTest for custom drivers on Boards.

 

Hello Anas,

            Thank you for the reply.

 

So it means just like running an application, i can run the testcases as an application from "zephyr/tests/xx_yy" folder on my board?

 

I tried it but i could find any prints related to my test case nor any effect on my device.

I am using nRF52 based board and seeing in RTT console.

 

Is there something i am missing in my understanding in the framework?

Regards,

Dhananjay G J

 

On Tue, Feb 6, 2018 at 3:42 PM, Nashif, Anas <anas.nashif@...> wrote:

Hi,

Running sanitycheck on a specific device is currently not supported, but it is a highly requested features and is planned. You could always go into the test you are interested in and just flash the binary to the device you are testing for now.

 

Anas

 

From: zephyr-users-bounces@... [mailto:zephyr-users-bounces@...] On Behalf Of dhananjay gj
Sent: Tuesday, February 6, 2018 9:13 AM
To: zephyr-users@...
Subject: [Zephyr-users] Running ZTest for custom drivers on Boards.

 

Hello All,

        I created a custom driver for one of our device on a board and wanted to write testcases for it. I can build the testcases by following other test driver folders like gpio or i2c , but these are not running the test_main() which is supposed to run the test suite that i wrote. And I also followed the zephyr documentation about using the sanitycheck script, but i think this just builds the project if i understood it. I would like to know how to run unit tests on the board for my devices instead of qemu on the PC.

This may be rookie question but i could find any documentation how about can we do this on boards if its possible. Any leads on this will be helpful.

Many thanks for the support.

Regards,
Dhananjay G J

 

2181 - 2200 of 2707