So, I've got this code below. The tone section sends 2 characters in morse code "CQ"; which equate to a tone sequence like this: long short long short long long short long
Initially I had the timing for each tone inverted from what is in the code, to match the tone sequence above. What I found was that after compilation, this sequence was *inverted*. So, I'd get short long short long short short long short; I found that if I inverted the duration then it played properly.
The funny thing is; I initially had a single character and it was correctly "played".
Is there something I'm not thinking of that would cause this behavior?
I realize there would be better ways to do this; I was simply fussing around with GCB and a breadboard and found this behavior a bit odd.
Thanks,
Joe
<pre>
'Chip model
#chip 16F88, 8
#config OSC=INTIO2
'#config OSCCON=0x70
'Set the pin directions
dir PORTB.0 out
dir PORTB.1 out
'Main routine
Start:
'Turn one LED on, the other off
SET PORTB.0 ON
SET PORTB.1 OFF
wait 250 ms
'Now toggle the LEDs
SET PORTB.0 OFF
SET PORTB.1 ON
wait 250 ms
SET PORTB.1 OFF
wait 500 ms
#define SoundOut PortB.2
SET PORTB.2 OFF
dir SoundOut OUT
wait 10 ms
Tone 550, 100
wait 50 ms
Tone 550, 300
wait 50 ms
Tone 550, 100
wait 50 ms
Tone 550, 300
wait 200 ms
Tone 550, 100
wait 50 ms
Tone 550, 100
wait 50 ms
Tone 550, 300
wait 50 ms
Tone 550, 100
wait 50 ms
'Jump back to the start of the program
goto Start
</pre>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So, I've got this code below. The tone section sends 2 characters in morse code "CQ"; which equate to a tone sequence like this: long short long short long long short long
Initially I had the timing for each tone inverted from what is in the code, to match the tone sequence above. What I found was that after compilation, this sequence was *inverted*. So, I'd get short long short long short short long short; I found that if I inverted the duration then it played properly.
The funny thing is; I initially had a single character and it was correctly "played".
Is there something I'm not thinking of that would cause this behavior?
I realize there would be better ways to do this; I was simply fussing around with GCB and a breadboard and found this behavior a bit odd.
Thanks,
Joe
<pre>
'Chip model
#chip 16F88, 8
#config OSC=INTIO2
'#config OSCCON=0x70
'Set the pin directions
dir PORTB.0 out
dir PORTB.1 out
'Main routine
Start:
'Turn one LED on, the other off
SET PORTB.0 ON
SET PORTB.1 OFF
wait 250 ms
'Now toggle the LEDs
SET PORTB.0 OFF
SET PORTB.1 ON
wait 250 ms
SET PORTB.1 OFF
wait 500 ms
#define SoundOut PortB.2
SET PORTB.2 OFF
dir SoundOut OUT
wait 10 ms
Tone 550, 100
wait 50 ms
Tone 550, 300
wait 50 ms
Tone 550, 100
wait 50 ms
Tone 550, 300
wait 200 ms
Tone 550, 100
wait 50 ms
Tone 550, 100
wait 50 ms
Tone 550, 300
wait 50 ms
Tone 550, 100
wait 50 ms
'Jump back to the start of the program
goto Start
</pre>