Internal Error compiling AN218

A private (members-only) forum for discussing all issues related to the Beta test of Native mode devices.
Locked
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Internal Error compiling AN218

Post by Don_Kirby »

I've been reading up on Mike's work with RS-485 Modbus protocols in AN218. After downloading the note's example code and modifying the Option TargetCPU statement to reflect the '24n, and increasing the receiveTaskStack size (at the behest of the compiler), the compiler output's the following:
Compiler wrote:Modbus.bas:346: Warning(8): subroutine will never return
Internal Error: an error occurred while building Modbus.zxc
>Exit code: 1
When compiled for the '24a, the result is fine:
Compiler wrote:Modbus.bas:346: Warning(8): subroutine will never return
No errors. Target device: ZX24a, Code: 2265 bytes, RAM: 344 bytes, Persistent memory: 0 bytes
>Exit code: 0
The subroutine warning seems as if it can be safely ignored in the instance.


-Don
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Internal Error compiling AN218

Post by dkinzer »

Don_Kirby wrote:

Code: Select all

Internal Error: an error occurred while building Modbus.zxc
We have reproduced the problem that you observed and have determined the cause. A solution is being developed.

A workaround is to change the type of sendDataToSlave():

Code: Select all

Private Function sendDataToSlave(ByVal id as Byte) as Byte
- Don Kinzer
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Re: Internal Error compiling AN218

Post by mikep »

Don_Kirby wrote:The subroutine warning seems as if it can be safely ignored in the instance.
The same warning about never returning from the infinite loop also occurs for other TargetDevices and can be safely ignored. You could eliminate the warning by adding

Code: Select all

--warn=no-never-returns
to the AN218.pjt file.

It would appear that the problem is caused by the code generation for accessing subtypes (Bit and Nibble). After rereading the function definition for PutBit, it turns out that Byte would probably be a better return type for the sendDataToSlave function in any case.

I had not got to testing all of my application notes so this is a good catch all round.
Mike Perks
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Re: Internal Error compiling AN218

Post by Don_Kirby »

mikep wrote:I had not got to testing all of my application notes so this is a good catch all round.
It would probably be a good idea to do a test compile (in native mode) for all of the sample code provided on the website before the public release of the 'n device line. I'm guessing that there won't be any major issues, but it may unearth some more items for Don's 'to do' list.

-Don
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Internal Error compiling AN218

Post by dkinzer »

mikep wrote:You could eliminate the warning by adding

Code: Select all

--warn=no-never-returns
to the AN218.pjt file.
An alternate strategy is to suppress the warning only for the specific routine:

Code: Select all

#pragma warning(push;8:off)
Private Sub slave(id as Byte)
    <code deleted for brevity>
End Sub
#pragma warning&#40;pop&#41;
mikep wrote:It would appear that the problem is caused by the code generation for accessing subtypes (Bit and Nibble).
Yes, but more specifically, a return value of those types. It has been resolved by correcting the code generated for that situation.
- Don Kinzer
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Re: Internal Error compiling AN218

Post by mikep »

Don_Kirby wrote:It would probably be a good idea to do a test compile (in native mode) for all of the sample code provided on the website before the public release of the 'n device line. I'm guessing that there won't be any major issues, but it may unearth some more items for Don's 'to do' list.
I have rebuilt all of my application notes and found the following additional problems. I have yet to test everything.

AN204: After changing the target device and rebuilding the code, the compiler gives me the following message:

Code: Select all

>"D&#58;\Program Files\ZBasic\zbasic.exe"  --target-device=ZX40n --directory="E&#58;\AN-204/" --project="AN-204.pjt"
No errors.  Target device&#58; ZX40n, Code&#58; 0 bytes, RAM&#58; 0 bytes, Persistent memory&#58; 0 bytes
AN208: This project does not build correctly unless the --verbose option is added either to the project file or the command line. This is a strange one.

AN210: In all cases the stack size should be increased to 70 bytes. The compiler suggest 60 but that is too little and causes an error for example when Atomic.bas is executed. Perhaps the compiler message should be changed and could mention System.TaskHeadroom as well. There is some hard-coding of task identifiers in the example code that could be made more generalized but that is a different problem.

AN212: Displays the same problem as AN208.
Mike Perks
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Re: Internal Error compiling AN218

Post by mikep »

dkinzer wrote:An alternate strategy is to suppress the warning only for the specific routine:

Code: Select all

#pragma warning&#40;push;8&#58;off&#41;
Private Sub slave&#40;id as Byte&#41;
    <code deleted for brevity>
End Sub
#pragma warning&#40;pop&#41;
This looks like a new function in this release and is documented in section 7.3.1 of the Language Reference Manual.
Mike Perks
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Re: Internal Error compiling AN218

Post by Don_Kirby »

mikep wrote: AN208: This project does not build correctly unless the --verbose option is added either to the project file or the command line. This is a strange one.
I suspect that there are still some timing issues with the new IDE/compiler. I routinely get a popup message asking "There are still commands executing that must complete before downloading. Continue waiting?". It's as if the left hand doesn't know what the right hand is doing during a compile/download. In your case, adding the --verbose option might be inducing a required delay. This could all be hogwash though, as I have no clue on the internals of the IDE nor the compiler.

-Don
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Internal Error compiling AN218

Post by dkinzer »

mikep wrote:I have rebuilt all of my application notes and found the following additional problems. I have yet to test everything.
Other than the stack size warnings and the sub-byte type return value problem, I believe that all of the problems arose due to the project file having a basename that is different from that of the main module. After correcting the code to handle this case correctly, all of the cited application note files compile without errors.
- Don Kinzer
Locked