Mega128 compiling error...

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Mega128 compiling error...

Post by vidor »

Hi,

I want to compile a new program done in Flowcode for AVR using the Atmega128. I am using the fcd file I found here on the forum.
When compiling the code it generates some error:
Generated by: Flowcode v3.3.5.45
Date: Tuesday, May 13, 2008 13:42:39
Licence: Professional
Registered to: Vidor Demeter


http://www.matrixmultimedia.com



Launching the compiler...

C:\Program Files\Matrix Multimedia\Flowcode_AVR\Tools\MX_bats\avra.bat atmega128 "C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.elf" "C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c" "C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.lst"


C:\Documents and Settings\Vidor\My Documents\Flowcode>"C:\PROGRA~1\MATRIX~1\FLOWCO~1\Tools\MX_bats\..\bin\avr-gcc.exe" -mmcu=atmega128 -Os -funsigned-char -o "C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.elf" "C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c"
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c: In function 'FCM_Disp_Data':
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:187: warning: passing argument 1 of 'FCD_LCDDisplay0_PrintString' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:202: warning: passing argument 1 of 'FCD_LCDDisplay0_PrintString' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:217: warning: passing argument 1 of 'FCD_LCDDisplay0_PrintString' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:242: warning: passing argument 1 of 'FCD_LCDDisplay0_PrintString' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c: In function 'FCM_Receive_Data':
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:372: warning: passing argument 1 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:372: warning: passing argument 5 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:383: warning: passing argument 1 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:383: warning: passing argument 5 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:394: warning: passing argument 1 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:394: warning: passing argument 5 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:405: warning: passing argument 1 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:405: warning: passing argument 5 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c: In function 'FCM_Read_Ana_Inputs':
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:512: warning: passing argument 2 of 'FCI_TOSTRING' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c: In function 'FCD_RS2320_SendRS232Char':
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1180: error: 'UCSRA' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1180: error: (Each undeclared identifier is reported only once
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1180: error: for each function it appears in.)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1187: error: 'UDR' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c: In function 'FCD_RS2320_ReceiveRS232Char':
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1212: error: 'UCSRA' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1239: error: 'UDR' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c: In function 'main':
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1736: error: 'UCSRA' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1751: error: 'UBRRL' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1752: error: 'UBRRH' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1760: error: 'UCSRB' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1777: warning: passing argument 2 of 'FCI_TOSTRING' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1842: warning: passing argument 5 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1843: warning: passing argument 2 of 'FCI_TOSTRING' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1844: warning: passing argument 1 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1844: warning: passing argument 3 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1844: warning: passing argument 5 of 'FCI_CONCATENATE' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1851: warning: passing argument 2 of 'FCI_TOSTRING' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1866: warning: passing argument 2 of 'FCI_TOSTRING' discards qualifiers from pointer target type
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1867: warning: passing argument 2 of 'FCI_TOSTRING' discards qualifiers from pointer target type

Error returned from [avr-gcc.exe]

Return code = 1

Flowcode was unable to compile the flowchart's C code due to the following errors:

If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.

FINISHED
It seems, in the fcd file, some variables aren't defined in the right manner, is it? :?:
When I compile with Mega88 or Mega168 as the target CPU everithing is fine. :mrgreen:
Can you help me out with this? :cry:

Thanks in advance
Regards
Vidor

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Mega128 compiling error...

Post by Sean »

Hello Vidor,

The long list of messages displayed during compilation includes several warnings generated by the string manipulation functions. The resuts of the compiler actions have been checked and the messages can be ignored.

The error messages are caused by the code in the RS232 component. I have attached a modified version of the .fcd file that might help to solve the RS232 problem (only USART0 can currently be used directly from Flowcode), and correct a problem with the ADCs (wrong port).
ATMEGA128.fcd
(9.24 KiB) Downloaded 482 times
As a temporary fix, the following code should be included in the 'Supplementary Code' definitions:

#define UCSRA UCSR0A
#define UCSRB UCSR0B
#define UCSRC UCSR0C
#define UBRRL UBRR0L
#define UBRRH UBRR0H
#define UDR UDR0

The ATMEGA128 was not on the original list of devices supported by Flowcode and has been added due to demand. Full support for the 128 is still being tested and should be available soon.

Please let us know of any more problems when using the ATMEGA128 with Flowcode.

User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Re: Mega128 compiling error...

Post by vidor »

Hi Sean,

Thanks for the help.
When I compile the file, one error is still coming up:
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1748: error: 'URSEL' undeclared (first use in this function)
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1748: error: (Each undeclared identifier is reported only once
C:\DOCUME~1\Vidor\MYDOCU~1\Flowcode\IndHeat_13-May-08_MT128.c:1748: error: for each function it appears in.)
I have one question about an LCD what I use:
it is an L2012 2x16. I tried to connect it but I get only flimmering the first line.
I tried to connect in Flowcode as shown in the attached picture.
There is only Data1 to Data4 in the Flowcode and in the picture (and the board) I have Data4 to Data7. Data1 to Data4 is not used on the board.
How can I connect to get out the data on my LCD?

Regards
Vidor
Attachments
MT128.JPG
MT128.JPG (72.24 KiB) Viewed 11756 times

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Mega128 compiling error...

Post by Sean »

Hello Vidor,

There is a definition in the new .fcd file that should prevent the compiler from looking for URSEL. If you have downloaded the fcd file to your Flowcode fcd folder you will need to close and re-open your program before the change is recognised.

You can set up the LCD connections in the Flowcode LCD component properties page as follows:
LCD_PORTC.JPG
LCD_PORTC.JPG (28.49 KiB) Viewed 11746 times
The Flowcode LCD component does not use the R/W line so an output command will be required to force PORTC1 low at the start of your program.

User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Re: Mega128 compiling error...

Post by vidor »

Hi Sean,

Thanks for the help.
I missed the R/W line... so I have to implement that. Thank you.
I connected the PortC1 to ground and it started, but the text it seems to flashing...
Tommorrow I will set an output command to force PORTC1 low at the start of the program.

Best regards
Vidor

User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Re: Mega128 compiling error...

Post by vidor »

Hi,

Everything seems to work but communication.
After some searching I find out that the AVR-mt-128 board uses USART1 as communication.
(only USART0 can currently be used directly from Flowcode)
How can I change to use the USART1 instead?

Regards
Vidor

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Mega128 compiling error...

Post by Sean »

Hello Vidor,

Hopefully the temporary fix for the compilation errors has also provded us with a simple solution to the UART selection problem.

It should be possible to change the definitions that were written into the supplementary code section to reference USART1 instead of USART0

The supplementary code should now be:

#define UCSRA UCSR1A
#define UCSRB UCSR1B
#define UCSRC UCSR1C
#define UBRRL UBRR1L
#define UBRRH UBRR1H
#define UDR UDR1

Please let me know if this solves the problem.

User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Re: Mega128 compiling error...

Post by vidor »

Hi Sean,

It seems to work. My problem is that I can't get right values trough RS232.
I'm sending 155 and I get at the PC-side 1551|5

Regards
Vidor

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Mega128 compiling error...

Post by Sean »

Hello Vidor,

I don't know where the extra characters are appearing from.

Some initial questions:

Are you using Hyperterminal on the PC?
Are you sending characters from Hyperterminal to the Mega128 and transmitting them back, or is the Mega128 generating the characters itself?
Do you have local echo enabled in Hyperterminal?
Are you sending <CR> from the Mega128 after each set of digits?
Are you sending <LF> from the Mega128 after each set of digits, or have you enabled automatic line feeds in Hyperterminal?
Are you using hardware handshaking?
Is the system clock frequency set correctly in Flowcode (default is usually for a 16000000Hz crystal)?
Is the Mega128 running from its internal oscillator.
Have the fuses been set correctly?
Could you send me a copy of your program and the fuse setting values you are using?

User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Re: Mega128 compiling error...

Post by vidor »

Hi Sean,
Are you using Hyperterminal on the PC?
Yes.
Are you sending characters from Hyperterminal to the Mega128 and transmitting them back, or is the Mega128 generating the characters itself?
I am sending characters to Mega128 and that transmitting them back.
Are you sending <CR> from the Mega128 after each set of digits?
No.
Are you sending <LF> from the Mega128 after each set of digits, or have you enabled automatic line feeds in Hyperterminal?
No.
Are you using hardware handshaking?
No.
The right clock frequency is set.
No, from a 16Mhz external crystal.
I'm sending the communications part of the program.
If you want to see the entire program and see if you can help me out with the entire communication problem, I can send it to you in private way.

My best regards
Vidor
Attachments
IndHeat-128-190508.fcf_avr
(5 KiB) Downloaded 410 times

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Mega128 compiling error...

Post by Sean »

Hello Vidor,

Unfortunately our Atmega128 test equipment will not be available until early tomorrow. I have tested your program on an Atmega32 using the Hyperterminal 'Send Text File' function to transfer a Notepad file containing the characters 155. Everything worked correctly, so it should not be necessary for you to send the full program.

I will run the program on the 128 when it becomes available.

User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Re: Mega128 compiling error...

Post by vidor »

Hi Sean,

Now I can send i.e.: 02188 and I get back from the Mega128 02<0>188<0> which is OK.
Now the problem is that when I simulate, I can send the number 02188 every time one after one, but from Mega128 I get the 02<0>188<0> only one time. If I restart the MCU I receive just one time again even I send the numbers several times.
I send you the code, I can not find the wrong part in it.

Thanks in advance
Vidor
Attachments
IndHeat-128-190508.fcf_avr
(7 KiB) Downloaded 426 times

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Mega128 compiling error...

Post by Sean »

Hello Vidor,

I have attached a slightly modified version of your program that seems to respond more reliably to the text strings.
IndHeat-128-190508a.fcf_avr
(10 KiB) Downloaded 342 times
I have ensured that each string of received characters (ID and Value) is terminated correctly with a 0. This is essential when you manipulate a string variable as an array. Without the 0, it is possible for string functions to overrun the end of a string and corrupt the memory space of other variables.

There is a possible timing problem when detecting the two ID characters. The program spends almost 50% of its time waiting for the first ID character, and almost 50% of its time waiting for the second ID character. When the first ID character is received by the RS232 component, it is equally likely that it will be detected as the second ID character - with the first character being returned as 255 (no character received) - causing the ID compare to fail.

I have changed the RS232 timeout values so that the progam waits much longer for the first character than for the others (which will follow immediately) so this gives a better chance of the first character in an RS232 string being received while testing for the first ID character.

It might be better to test for the reception of only the first RS232 character to decide whether a transmission has been detected, then continue to receive and test the remaining characters. This would remove almost all the timing problems.

User avatar
vidor
Posts: 42
Joined: Mon Jan 28, 2008 4:56 pm
Location: Sweden

Re: Mega128 compiling error...

Post by vidor »

Hi Sean,

Thank you very much for your help.
It seems to work in the right way now.

Best regards
Vidor

Post Reply