Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This section refers to the following sample application(s):

  • 03-radioTest

This application is new to OCSDK 1.2.0

This sample


The 02-radioTest Sample Application

The application provides five CLI functions (available by typing help) for setting the state of pin DP2 (GPIO 21):

  • initPer - sets the initial period, in ns.  By default, it is set to DN_PWM_8P9MS (8.9 ms). Cannot be called when the PWM is open.
  • initDuty - sets the initial duty cycle, expressed as the asserted portion of the period in ns.  
  • openPWM - opens the DN_PWM_DEV_ID device (PWM0,  LTC5800 pin 49). The device must be opened before enabling/disabling the PWM. 
  • enablePWM - enables the PWM signal output on PWM0.
  • disablePWM - disables the PWM signal output on PWM0
  • setDuty - sets the current duty cycle, expressed as the asserted portion of the period in ns. 
  • closePWM - closes the pwm device and disable output. The PWM must be closed before changing the period.

Each CLI command prints a confirmation:

PWM app, ver 1.2.0.1
SmartMeshIP stack, ver 1.4.1.6

initPer 8888889
Config Period: 8888889

>initDuty 2222222
Initial duty cycle: 2222222

>openPWM
Open PWM with period=8888889 and initial duty cycle=2222222 

>enablePWM
enabledPWM

>setDuty 4444444
New duty cycle: 4444444

>disablePWM
Disabled PWM

>closePWM
ClosedPWM

Implementation Details

The 02-pwm sample application uses the Helper Modules to initialize the CLI Module and for interaction with the local interface. It passes JOIN_NO in the fJoin flag when initializing the local module in the loc_task_init() to prevent the local module from attempting to join. It does not start any application tasks - it relies solely on CLI commands to drive the PWM to demonstrate its features.

The application defines a default period, DEFAULT_PERIOD, in ns, and a default duty cycle that is 50% of the default period (DEFAULT_PERIOD/2).

While the period can be set to any value, there is an enumerated list of guaranteed glitch-free periods. When using other periods, enabling the pwm may produce a single cycle of the pin being asserted for an arbitrary portion of the period. For this reason, it is recommended to use one of the periods defined in dnm_pwm.h.



  • No labels