Problem about PWM2 driver

14 posts / 0 new
Last post
sklin
Offline
Last seen:5 years 9 months ago
Expert
加入:2014-08-12 08:01
Problem about PWM2 driver

Hi Dialog
I'm doing a experiment about PWM2 with the sample project "sample128".

Before I configure the PWM2,everything is normal(scan the device by phone),
but if I configure P1_2 to output the pwm2 signal,and enable the pwm2.
I can't get the advertising of the device(scan the device by phone).

What I have configured is like below:
void GPIO_reservations(void)
{
...
RESERVE_GPIO( PWM2_OUT, GPIO_PORT_1, GPIO_PIN_2,PID_PWM2);
}
void set_pad_functions(void)
{
...
GPIO_ConfigurePin( GPIO_PORT_1 ,GPIO_PIN_2,OUTPUT,PID_PWM2,false);
}
void periph_init(void)
{
...
set_tmr_enable(CLK_PER_REG_TMR_ENABLED);
set_tmr_div(CLK_PER_REG_TMR_DIV_8);
timer2_init(HW_CAN_PAUSE_PWM_2_3_4,PWM_2_3_4_SW_PAUSE_DISABLED,1000);
timer2_set_pwm2_duty_cycle(100);
}
Now I can get the output signal of pwm2,but the device can't do advertising,
and if I remove the code what I add in periph_init(),it can do advertising again.
what‘s the problem.(I have undef the sleepmode)

sklin
Offline
Last seen:5 years 9 months ago
Expert
加入:2014-08-12 08:01
If I change the frequency

If I change the frequency parameter to 16000,it work well.
timer2_init(HW_CAN_PAUSE_PWM_2_3_4,PWM_2_3_4_SW_PAUSE_DISABLED,16000);
Although the problem has solved now ,but I want to known why if I set frequency parameter value with a small number it will work abnormal ?

sklin
Offline
Last seen:5 years 9 months ago
Expert
加入:2014-08-12 08:01
Why is there no answer to my

Why is there no answer to my questions ?!

PY_Dialog
Offline
Last seen:2 years 9 months ago
工作人员
加入:2014-08-25 09:59
Hi Sklin,

Hi Sklin,

Do your use the sample128 program in our SDK? Which version do you use? I will try and get back to you later.

Regards!
PY

sklin
Offline
Last seen:5 years 9 months ago
Expert
加入:2014-08-12 08:01
Hi PY

Hi PY
The version of the SDK isDA14580_SDK_3.0.4.0

PY_Dialog
Offline
Last seen:2 years 9 months ago
工作人员
加入:2014-08-25 09:59
Hi Sklin,

Hi Sklin,

I tried the code your wrote and it can do both pwm(1000 frequency) and BLE advertise in my machine. Did you forget mention of any other settings?

Regards!
PY

sklin
Offline
Last seen:5 years 9 months ago
Expert
加入:2014-08-12 08:01
The other settings are

The other settings are irrespective.Like configure uart2,GPIO input and so on.
Sometimes it can advertising,but if I use a phone connect to it ,and then read characteristic,it will disconnect and can't advertising again.
Everything is OK if I set the pwm2 frequency with 16000.
I have try it many times.
Did you have try to read or write characteristic after establish connection?

PY_Dialog
Offline
Last seen:2 years 9 months ago
工作人员
加入:2014-08-25 09:59
Yes, I used our

Yes, I used our connectionmanager and can connect, disconnect, reconnect and read out characteristic smoothly. What program you used in your phone to connect to the board? Maybe due to the program you used in your phone.

sklin
Offline
Last seen:5 years 9 months ago
Expert
加入:2014-08-12 08:01
If I use a USBDongle as a

If I use a USBDongle as a central device.
It can scan the da14580 everytime,and can connect,read out charateristic.Everything is OK.

But if use my phone as a central device.
It can scan and connect the da14580 at first,but disconnect while reading out characteristics.
and then can't scan the da14580(But the USBDongle can scan da14580 this time).

It seems the problem is due to my phone.
But I still can't accept this ,because it can't explain why it work well if I set the pwm2 with the low frequency.
Oh,What a trouble~~~

PY_Dialog
Offline
Last seen:2 years 9 months ago
工作人员
加入:2014-08-25 09:59
Hi Sklin,

Hi Sklin,

Did you use of any sleep mode?

Regards!
PY

sklin
Offline
Last seen:5 years 9 months ago
Expert
加入:2014-08-12 08:01
Hi PY

Hi PY
不,我不使用任何睡眠模式,我相依igure the sleep mode in da14580_config.h with:
#undef CFG_EXT_SLEEP
#undef CFG_DEEP_SLEEP
I will try to detect the adverting interval and connection interval(maybe there is something abnormal).
Any case ,thank you very much.

giuseppe
Offline
Last seen:4 years 8 months ago
Expert
加入:2015-03-25 13:34
I have the same problem

I have the same problem

MT_dialog
Offline
Last seen:1 month 19 hours ago
工作人员
加入:2015-06-08 11:34
Hi guiseppe,

Hi guiseppe,

What are the pins that you are using to output the PWM pulse ? In case that port 1_2 and port 1_3 is used, please note that those pins interfere with the 16MHz oscillator causing BLE link loss, etc, those pins should only be used for static or low speed signals (i.e. a push button) and not for high speed signals. If you route the PWM output to pin 1_0 for example you should be ok. For more info you can have a look at the AN-B-009.pdf Crystal oscillator PCB layout guidelines p.5.

Thanks MT_dialog

giuseppe
Offline
Last seen:4 years 8 months ago
Expert
加入:2015-03-25 13:34
I must to change the pcb. I

I must to change the pcb. I would have preferred that this information had been written in the IC datasheet.