My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
-- Title: Test program for 1 PWM channel, using a LED
-- Author: Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
-- Adapted-by:
-- Compiler: >=2.4i
-- Revision: $Revision$
--
-- This file is part of jallib (http://jallib.googlecode.com)
-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
--
-- Description: this sample show how to use PWM in low resolution mode.
-- It progressively light up and down a LED. Sweet...
--
--
--
--
-- This file has been generated on Sun Feb 8 11:05:54 2009, from:
-- * board: board_16f88_sl.jal
-- * test : test_pwm_led.jal
--


;@jallib section chipdef
-- chip setup
include 16f88

;--
-- We'll use internal oscillator. It work @ 8MHz
pragma target clock 8_000_000
pragma target OSC INTOSC_NOCLKOUT
-- Specify no postscaler, ie. really runs @8MHz
OSCCON_IRCF = 0b_111
pragma target WDT disabled -- no watchdog
pragma target LVP disabled -- no low-voltage programming
pragma target CCP1MUX RB0 -- ccp1 pin on B0
pragma bootloader long_start -- for TinyBootloader

;@jallib section ccp
-- ccp setup
var volatile bit pin_ccp1_direction is pin_b0_direction

enable_digital_io()

-- Configure PWM
pin_ccp1_direction = output
include pwm_hardware
pwm_max_resolution(1)
pwm1_on()

forever loop
var byte i
i = 0
-- loop up and down, to produce different duty cycle
while i < 250 loop
pwm1_set_dutycycle(i)
_usec_delay(10000)
i = i + 1
end loop
while i > 0 loop
pwm1_set_dutycycle(i)
_usec_delay(10000)
i = i - 1
end loop
-- turning off, the LED lights at max.
_usec_delay(500000)
pwm1_off()
_usec_delay(500000)
pwm1_on()

end loop

Change log

r2760 by sebastien.lelong on Jul 31, 2011   Diff
added Revision: field + svn:keywords
Revision property on all existing *.jal
files. Also add to normalize EOL chars to
avoid mixed ones
Go to: 
Project members, sign in to write a code review

Older revisions

r1334 by sebastien.lelong on Sep 20, 2009   Diff
pwm tutorial part 1 from jalliblog
All revisions of this file

File info

Size: 1743 bytes, 70 lines

File properties

svn:keywords
Revision
Powered by Google Project Hosting