Difference: BoardSupportPackageWB (21 vs. 22)

Revision 222020-12-28 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
%DASHBOARD{ section="banner"
Line: 195 to 195
 

Using the PWM (Analog Output Pins)

Changed:
<
<
Only three port pins are supported so far. The TIMER1 is used for the timebase, time resolution is 1 us (32 MHz SysClk divided by 32). The PWM scale is from 0 (0 % duty cycle) to 1000 (100 % duty cycle), this results in a PWM frequency of 1 kHz. If you need higher PWM frequencies, decrease the divider and/or the scale.
>
>
Only three port pins are supported so far. The 16 bit TIMER1 is used for the timebase, time resolution is 1 us (32 MHz SysClk divided by 32). The PWM scale is from 0 (0 % duty cycle) to 1000 (100 % duty cycle), this results in a PWM frequency of 1 kHz. If you need higher PWM frequencies, decrease the divider and/or the scale.
  PWM port pins: D6 (TIM1CH1), D9 (TIM1CH2), D3 (TIM1CH3)
Line: 214 to 214
 
Changed:
<
<
>
>
 

Using Input Capture and Output Compare

Time Base

Added:
>
>
Default timer resolution is 1 us. The 32 bit TIMER2 is used as time base for Input Capture / Output Compare. For a 5 s period 5'000'000 cycles are needed. All channels (input capture / output compare) use the same time base.
: period ( -- )
  5000000 ICOCperiod! \ 5 s period
  ICOCstart
  begin
     waitperiod
     cr .time
  key? until
  key drop 
;
 

Output Compare

Changed:
<
<

Input Capture

>
>
: oc-toggle ( -- )
  5000000 ICOCperiod! \ 5 s period
  ICOCstart
  3 0 OCmod  1000000 0 OCstart \ toggle D0 after 1 s
  3 1 OCmod  2000000 1 OCstart \ toggle D1 after 2 s
  3 5 OCmod  3000000 5 OCstart \ toggle D5 after 3 s 
  begin
     waitperiod
     cr .time
  key? until
  key drop 
;
 
Added:
>
>
When you abort (hit any key) the program, the timer still runs and control the port pins.
 
Deleted:
<
<
 
Changed:
<
<
>
>

Input Capture

This sample program measures the time between the edges on port A2. if no event occurs within 2 seconds, "timeout" is issued. Hit any key to abort program.

: ic-test ( -- )
  6 2 dmod \ input capture on A2

 
Added:
>
>
ICOCstart 2 ICstart \ both edges ICOCcount@ ( -- count ) begin 2000 \ 2 s timeout ICwait ( -- old-capture capture ) cr dup 0= if ." timeout" drop else dup rot ( -- capture capture old-capture ) - 1000 / . ." ms" then key? until key drop drop ICstop ;
 
Added:
>
>
 
Added:
>
>
 
Added:
>
>
 

-- Peter Schmid - 2020-04-11

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback