HI Jallians,
Here is ' first release' of my library for playing music with hardware PWM from 877. Fell free and happy to use it in your projects. 877 must be clocked at 4MHz, only two octave are included here. I'm working now for variable notes length ( 1, 1/2, 1/4, 1/8, 1/16 ) Some simple ideas are welcome !
Wouter, playing with banks in JAL is painful ! Help us, although we gone die...
-- libraries include f877_04 include jpicm -- a modified jpic library for 877 registers include jdelay -- config pins -- var bit pwm1 is pin_c2 -- pin_c2_direction = output -- procedure tempo ( byte in flow ) is var byte lenght = 10 var byte pause pause = lenght / 2 -- end procedure procedure frequency ( byte in period, byte in prescale ) is asm movf period, w bank_1 asm movwf f877_pr2 bank_0 f877_ccpr1l = period / 2 -- set duty cycle at approx 0.5 pin_c2_direction = output -- output the waves if prescale == 16 then f877_t2con = 0b_0000_0110 -- tmr2 on, prescale=16 elsif prescale == 4 then f877_t2con = 0b_0000_0101 -- tmr2 on, prescale=4 elsif prescale == 1 then f877_t2con = 0b_0000_0100 -- tmr2 on, prescale=1 end if f877_ccp1con = 0b_0000_1100 -- pwm mode on end procedure procedure stop is delay_100mS ( lenght ) f877_ccp1con = 0 -- PWM off delay_100ms ( pause ) end procedure procedure DO1 is frequency ( 238, 16 ) stop end procedure procedure REb1 is frequency ( 224, 16 ) stop end procedure procedure RE1 is frequency ( 212, 16 ) stop end procedure procedure MIb1 is frequency ( 200, 16 ) stop end procedure procedure MI1 is frequency ( 189, 16 ) stop end procedure procedure FA1 is frequency ( 178, 16 ) stop end procedure procedure FAd1 is frequency ( 168, 16 ) stop end procedure procedure SOL1 is frequency ( 158, 16 ) stop end procedure procedure LAb1 is frequency ( 149, 16 ) stop end procedure procedure LA1 is frequency ( 141, 16 ) stop end procedure procedure SIb1 is frequency ( 133, 16 ) stop end procedure procedure SI1 is frequency ( 126, 16 ) stop end procedure procedure DO2 is frequency ( 118, 16 ) stop end procedure procedure REb2 is frequency ( 112, 16 ) stop end procedure procedure RE2 is frequency ( 105, 16 ) stop end procedure procedure MIb2 is frequency ( 99, 16 ) stop end procedure procedure MI2 is frequency ( 94, 16 ) stop end procedure procedure FA2 is frequency ( 88, 16 ) stop end procedure procedure FAd2 is frequency ( 83, 16 ) stop end procedure procedure SOL2 is frequency ( 79, 16 ) stop end procedure procedure LAb2 is frequency ( 74, 16 ) stop end procedure procedure LA2 is frequency ( 70, 16 ) stop end procedure procedure SIb2 is frequency ( 66, 16 ) stop end procedure procedure SI2 is frequency ( 252, 4 ) stop end procedure procedure DO3 is frequency ( 238, 4 ) stop end procedure -- main program forever loop DO1 REb1 RE1 MIb1 MI1 FA1 FAd1 SOL1 LAb1 LA1 SIb1 SI1 DO2 delay_1S ( 3 ) DO1 RE1 MI1 FA1 SOL1 LA1 SI1 DO2 delay_1S ( 3 ) DO2 RE2 MI2 FA2 SOL2 LA2 SI2 DO3 delay_1S ( 3 ) DO1 MI1 SOL1 DO2 DO2 SOL1 MI1 DO1 DO2 MI2 SOL2 DO3 DO3 SOL2 MI2 DO2 delay_1S ( 3 ) end loop
file: /Techref/piclist/jal/music-vs.htm, 3KB, , updated: 2000/10/4 11:28, local time: 2024/11/21 15:02,
3.135.209.107:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://ecomorder.com/techref/piclist/jal/music-vs.htm"> PIC JAL IO Routine </A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.