I have encountered a problem with the "Tone" statement.
I needed to create the sound of a two-tone siren, so I got a PIC12F683 clocked at 8MHz to be able to generate these two tones.
The simplest thing to have two notes of 660 and 466 Hz for a duration of 750 mS was to use the "Tone" instruction.
I encountered this problem that is generated both with the micro and in emulation with SimulIDE.
In practice, if I play the two notes with an interval of 750 mS the micro generates only the first tone at 466Hz.
If I bring the interval to 1500 mS the micro generates the first note at 466Hz for a few minutes, then the normal cycle begins.
The same problem happens with simulation.
At first there is a 466 Hz output on the SOUNDOUT Pin. It does not change to 660 Hz after 750 ms. After about 10 minutes or so of outputting a steady 466 Hz , it begins operating as expected.
It will continue operating as expected as long as power is not removed. The chip can be reset, or even reprogrammed and it operates as expected. But once power is removed it takes 10 min or so to start operating correctly. ... Quite odd
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Where is TonePeriod? Actually where is the Tone code? I can't see it looking through GCB folder. It's not an include.
In Tone help it says "Generate a specified tone for a specified duration in terms of a frequency of a specified Mhz and units of 10ms".
MHz ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I apologize to everyone for being late, but I've been busy on business.
In fact, inserting the definition "USELEGACYFORNEXT" the program runs well.
I would like to understand what was going on in the program.
Taking a first look at the ASM source it seemed all right.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is a bug in the new FOR-NEXT loop where the loop variable was incorrectly cast.
Save the errant asm today. Then, tomorrow download the latest patches ( build 1005) then recompile. Then, compare the ASM. You will see the variables are Words not Bytes for two loop variables.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
;For ToneLoop = 1 to ToneDurationmovlw1movwfTONELOOPSysForLoop1;For ToneLoop2 = 1 to ToneFrequencymovlw1movwfTONELOOP2
Released 0.98.07 build 1005 ASM
;For ToneLoop = 1 to ToneDurationmovlw1movwfTONELOOPclrfTONELOOP_H'this was missingSysForLoop1;For ToneLoop2 = 1 to ToneFrequencymovlw1movwfTONELOOP2clrfTONELOOP2_H'this was missing
The compiler was treating the ToneLoop and ToneLoop2 variables as byte type therefore failing to clear the _H byte.
Sorry. All sorted.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When did the for-next problem occur? I've never had any problems with for next... if it's a loop of more than 255 I use a word value with the for variable. I'll download the latest gcb as a matter of course.
In any gcb version, where does it show the build number... when assembling it only says compiler version v0.98.07 2021-05-27. on my current gcb.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Stan. Read the thread from the start and you will see that the @jackjames reported some very odd behaviour which was properly analysed as a major issue in the compiler.
Re the version.
Use the IDE show the version, or, look at the top line of the ASM.
;Program compiled by Great Cow BASIC (0.98.07 2021-07-24 (Windows 64 bit) : Build 1005)
Last edit: Anobium 2021-07-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear Even, I do check the forum regularly and saw the for next "Problem".
I'll re-read it but after all these years, for next don't work???
Downloading latest gcb version from Sourceforge is an hour. Maybe they are having problems.
Had to update gcb to two pc's ethernet and so slow.
Thanks for the work everyone's done to gcb.
The RC releases were ok but patches???
The useful info in the forum gets lost so quickly.
ps the version can be gcb version..rc 5 or whatever but no easy...for me. way to see what version of gcb I'm using and things change fast.
Last edit: stan cartwright 2021-07-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I always go for the full gcb install... dunno why, I don't use the extras but install anyway.
I use avr mostly but some pics with built in op amp look tempting. I guess I'll have to use the PPS tool and look up data sheets...maybe stick to avr and use external op amp.
Whatever's easiest :) Regards, happy user
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Personally I try to avoid updating at all costs. I find it takes me so long to get everything working again after updating I would rather do anything than upgrade!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have encountered a problem with the "Tone" statement.
I needed to create the sound of a two-tone siren, so I got a PIC12F683 clocked at 8MHz to be able to generate these two tones.
The simplest thing to have two notes of 660 and 466 Hz for a duration of 750 mS was to use the "Tone" instruction.
I encountered this problem that is generated both with the micro and in emulation with SimulIDE.
In practice, if I play the two notes with an interval of 750 mS the micro generates only the first tone at 466Hz.
If I bring the interval to 1500 mS the micro generates the first note at 466Hz for a few minutes, then the normal cycle begins.
The same problem happens with simulation.
Toggleled could be LED = not LED.
Did not know of do forever...loop
why not do...loop ?
PS , I thought GPIO was only for AVR chips
Last edit: stan cartwright 2021-07-23
The Tone Duration is in 10 ms units. So for 750 ms that would be a value of 75.
Try this:
Last edit: William Roth 2021-07-23
To simplify toggling of the LED you might try this instead of calling a subroutine:
So I tried the above code on a 18F27Q43.
At first there is a 466 Hz output on the SOUNDOUT Pin. It does not change to 660 Hz after 750 ms. After about 10 minutes or so of outputting a steady 466 Hz , it begins operating as expected.
It will continue operating as expected as long as power is not removed. The chip can be reset, or even reprogrammed and it operates as expected. But once power is removed it takes 10 min or so to start operating correctly. ... Quite odd
Try adding
dim TonePeriod as word
Where is TonePeriod? Actually where is the Tone code? I can't see it looking through GCB folder. It's not an include.
In Tone help it says "Generate a specified tone for a specified duration in terms of a frequency of a specified Mhz and units of 10ms".
MHz ?
@Stan
The code is in ... \lowlevel\sound.h
@ JackJames
Add this line to your code.
This should resolve for now.
I apologize to everyone for being late, but I've been busy on business.
In fact, inserting the definition "USELEGACYFORNEXT" the program runs well.
I would like to understand what was going on in the program.
Taking a first look at the ASM source it seemed all right.
There is a bug in the new FOR-NEXT loop where the loop variable was incorrectly cast.
Save the errant asm today. Then, tomorrow download the latest patches ( build 1005) then recompile. Then, compare the ASM. You will see the variables are Words not Bytes for two loop variables.
Thank you for your explanation.
I will release v0,.98,07 build 1005 today. It is a mandated update.
The FOR-NEXT issue identified needs a critical fix.
Look for the new release today.
This issue impacts PIC/AVR/LGT AM
Released 0.98.07 ASM
Released 0.98.07 build 1005 ASM
The compiler was treating the ToneLoop and ToneLoop2 variables as byte type therefore failing to clear the
_H
byte.Sorry. All sorted.
I downloaded the file to perform a complete new installation.
This error occurs:
Close the Preferences Editor. :-)
Thanks
When did the for-next problem occur? I've never had any problems with for next... if it's a loop of more than 255 I use a word value with the for variable. I'll download the latest gcb as a matter of course.
In any gcb version, where does it show the build number... when assembling it only says compiler version v0.98.07 2021-05-27. on my current gcb.
@Stan. Read the thread from the start and you will see that the @jackjames reported some very odd behaviour which was properly analysed as a major issue in the compiler.
Use the IDE show the version, or, look at the top line of the ASM.
Last edit: Anobium 2021-07-25
Dear Even, I do check the forum regularly and saw the for next "Problem".
I'll re-read it but after all these years, for next don't work???
Downloading latest gcb version from Sourceforge is an hour. Maybe they are having problems.
Had to update gcb to two pc's ethernet and so slow.
Thanks for the work everyone's done to gcb.
The RC releases were ok but patches???
The useful info in the forum gets lost so quickly.
ps the version can be gcb version..rc 5 or whatever but no easy...for me. way to see what version of gcb I'm using and things change fast.
Last edit: stan cartwright 2021-07-25
I always go for the full gcb install... dunno why, I don't use the extras but install anyway.
I use avr mostly but some pics with built in op amp look tempting. I guess I'll have to use the PPS tool and look up data sheets...maybe stick to avr and use external op amp.
Whatever's easiest :) Regards, happy user
:-)
Personally I try to avoid updating at all costs. I find it takes me so long to get everything working again after updating I would rather do anything than upgrade!
If you are using ANY version of 0.98.07 then it is a mandated upgrade. The FOR-NEXT is critical update.
And, automate the upgrade. The updates will be coming.
Last edit: Anobium 2021-07-26
I wish I knew how to automate the upgrade. Honestly, it takes me hours.