BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Tue Jul 17, 2018 6:41 pm

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: QnD Nano HPWM Demo program
PostPosted: Tue Oct 20, 2009 7:15 am 
Offline
Master

Joined: Mon Aug 18, 2008 1:26 am
Posts: 799
Location: CA bay Area
11/16/09 - Added. This is a followup to the note below.
Although the Nano18 data sheet indicates both P0 and P3 have HPWM capability, this code is hardwired in the config settings to use only P3 for all HPWM activity. P0 will never produce an HPWM signal!
11/15/09 - Edited. Changed original variable name "per" to "period". Built OK, no problem.
Just happened to test this new version against a Nano18 and discovered a problem. The Nano18 only outputs on P3 no matter which pin (P0 or P3) you specifiy. A Nano40 outputs to the pin (P9 or P10) you specify, and this code was originally tested against a Pro28 module, so it works with everything but the Nano18. I just sent a problem report to BMicro.

This is the code I left for another forum post earlier. I figured it would be helpful to post a sticky of this so everyone has a guide. Some HPWM commad usage have changed from the old manual examples and posts elsewhere, so this is golden. Enjoy!
Code:
;*** Nano HPWM demo, 19OCT2009 By KenJJ ***
; This is best monitored with a dual-channel oscilloscope
; Clever users will figure how to use COUNT on another pin to follow the frequency!

sel1 con 10 ; this is the first hardware pwm channel. This is on P10. "0" works too.
sel2 con 9  ; this is the second hardware pwm channel. This is on P9. "1" works too.
period var word
duty var word ; positive duty cycle

for period = 100 to 9100 step 500  ; set period value in FOR-NEXT loop, starts with 83KHz signal
duty = per_iod/2 ; 50% duty cycle
; Exercise first Hardware PWM
;hpwm pin, period, duty (syntax reminder)
hpwm sel1, period, duty
pause 2000 ;wait 2 sec
hpwm sel1, 0, 0  ; disable first HPWM
pause 1000 ;wait 1 sec

; Exercise second Hardware PWM
hpwm sel2, period, duty
pause 2000 ;wait 2 sec
hpwm sel2, 0, 0  ; disable second HPWM
pause 1000 ;wait 1 sec
next ; next loop

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO