This is a long standing issue where the units of the WAIT command are incorrect. The errors issued by the compiler are meaningless.
Example 1
#chip10f200wait1010us'where this is intended to be 10 10us
Error message is:
10usBug.gcb (2): Warning: Inaccurate microsecond delay due to use of variable at the current clock speed
Example 2
#chip 16f1503
#define AD_Delay 4 10 us
ADCVAlue=ReadAD(an0)
Error messages are:
a-d.h (1682): Warning: Inaccurate microsecond delay due to use of variable at the current clock speed
a-d.h (1682): Error: Incorrect parameters in Set, expected: Set variable.bit status
Example 3
#chip16f18855'USART settings for USART1
#defineUSART_BAUD_RATE9600
#defineUSART_TX_BLOCKING
#defineUSART_DELAY010usHSerPrint""
Error message is:
usart.h (682): Error: Invalid variable name: 010
The root cause is the compiler is not correctly parsing the WAIT value parameter. After a few hours of hacking the code the following change to the compiler could resolve.
'Check the syntax of the Value... does it have a space or other error?IfInStr(Value," ")<>0Then'The Value has spaces but this cound be a calc like 'show_timer/4ms'ForUP=1toLEN(Value)lValueASC=ASC(MID(Value,UP,1))'walk the Value looking for NON numeric values.. if non numeric then we can assume that we have numbers only and numbers can be tested If(lValueASC<47ORlValueASC>57)andlValueASC<>32Then'this is NOT a numeric constantGotoNoTNumericConstantEndifNext'Test a numeric value of Value .. if Value <> Str(Val(Value)) then we have something like '1010'... error!IfValue<>Str(Val(Value))ThenLogErrorMessage("IncorrectWaitParameter"),OriginCurrLine=LinkedListDelete(CurrLine)GoToEndWaitCompileEndIfEndifNoTNumericConstant:
With the change above the following messages are now issued.
Example 1
#chip10f200wait1010us'where this is intended to be 10 10us
Error message is:
10usBug.gcb (2): Error: Incorrect time unit specified. This can be an indirect error from a subroutine - so, inspect all time based constants
Example 2
#chip 16f1503
#define AD_Delay 4 10 us
ADCVAlue=ReadAD(an0)
Error messages are:
10usBug.gcb (2): Error: Incorrect time unit specified. This can be an indirect error from a subroutine - so, inspect all time based constants
Example 3
#chip16f18855'USART settings for USART1
#defineUSART_BAUD_RATE9600
#defineUSART_TX_BLOCKING
#defineUSART_DELAY010usHSerPrint""
Error message is:
usart.h (936): Error: Incorrect time unit specified. This can be an indirect error from a subroutine - so, inspect all time based constants
Anyone spot any issues with this solution to the problem?
Evan
Last edit: Anobium 2021-10-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
'Patch 1041 10/10/2021'Check the syntax of the Value... does it have a space or other error?ExpandedValue=ReplaceConstantsLine(trim(Value),0)printValue,ExpandedValue,Str(Val(ExpandedValue))IfInStr(ExpandedValue," ")<>0Then'The Value has spaces but this cound be a calc like 'show_timer/4ms'ForUP=1toLEN(ExpandedValue)lValueASC=ASC(MID(ExpandedValue,UP,1))'walk the Value looking for NON numeric values.. if non numeric then we can assume that we have numbers only and numbers can be testedIf(lValueASC<47ORlValueASC>57)andlValueASC<>32Then'this is NOT a numeric constantGotoNoTNumericConstantEndifNext'Test a numeric value of Value .. if Value <> Str(Val(Value)) then we have something like '1010'... error!Iftrim(ExpandedValue)<>trim(Str(Val(ExpandedValue)))ThenLogErrorMessage("IncorrectWaitParameter"),OriginCurrLine=LinkedListDelete(CurrLine)GoToEndWaitCompileEndIfEndifNoTNumericConstant:'End of Patch 1041
Last edit: Anobium 2021-10-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a long standing issue where the units of the WAIT command are incorrect. The errors issued by the compiler are meaningless.
Example 1
Error message is:
10usBug.gcb (2): Warning: Inaccurate microsecond delay due to use of variable at the current clock speed
Example 2
Error messages are:
a-d.h (1682): Warning: Inaccurate microsecond delay due to use of variable at the current clock speed a-d.h (1682): Error: Incorrect parameters in Set, expected: Set variable.bit status
Example 3
Error message is:
usart.h (682): Error: Invalid variable name: 010
The root cause is the compiler is not correctly parsing the WAIT value parameter. After a few hours of hacking the code the following change to the compiler could resolve.
With the change above the following messages are now issued.
Example 1
Error message is:
10usBug.gcb (2): Error: Incorrect time unit specified. This can be an indirect error from a subroutine - so, inspect all time based constants
Example 2
Error messages are:
10usBug.gcb (2): Error: Incorrect time unit specified. This can be an indirect error from a subroutine - so, inspect all time based constants
Example 3
Error message is:
usart.h (936): Error: Incorrect time unit specified. This can be an indirect error from a subroutine - so, inspect all time based constants
Anyone spot any issues with this solution to the problem?
Evan
Last edit: Anobium 2021-10-11
Updated the code to handle Constants.
Last edit: Anobium 2021-10-11
Hi Evan.
Is the modified code available for download?
Build 1042 is uploaded.
Enjoy
Yes, from the patches in File. If you wait until I post 1042 later today.
Why have I not seen any problems using wait?
Cus, you have not come across the bug. It is very specific to
10us
and10ms
where the program has a space in the time parameter.But, if you had seen it.. you would have been scratching head, for a long time, looking for it.
I used pulsout 1500 10us instead of 150ms with rc servos and no problems but maybe pulseout is different to wait.
Just been told this is also fixed....
Again, a space in the time parameter. However, this was a silent failure where you got no warning the generated code was incorrect.
:-) Fixed.