unsigned long long int data types not supported

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

1. I am working on ATMEL ARM-Cortex-M ATSAML22N18A CPU and using ASF stack. It is giving warning for unsigned long long int data types. i.e. "ISO C90 doesn't support unsigned long long".

2. by default -std=gnu99 is set in compiler settings.  I tried using C99 as well. But no success.

3.  I am working ATMEL studio 7.0 for ARM cortex-M0+.  Also I tried to use uint64_t typedef data type which is used in most of ASF drivers as well. I have also not got error for uint64_t variable. But when load uint64_t variable with value more 32bit i.e. e.g. 0x1FFFFFFFF; this gives warning "use of C99 long long interger constant [-Wlong long] "

But even though i haven't got error, i got only warning, I am not getting the desired results. Please try this on ARM - ATMEL studio and select CPU = ATSAML22N18A.

4.  I have configured stdio driver and I am using printf to print data on terminal utilities. Does it support uint64_t values to print?

Please find attached screenshots.

Please suggest to add support for unsigned long long int data type.

Thanks,

Warm Regards,

Nilesh.

Attachment(s): 

Nilesh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Seems to work ok:  ATSAME70 Xpln.

 

ASF standard defaults:

 

int main(void)
{	
	uint64_t tester;
	tester =  0x1FFFFFFFFllu;
	printf("tester %llx\r\n",tester);
	tester++;
	printf("tester %llx\r\n",tester);
....
Result:
-- SAME70-XPLD --
-- Compiled: Aug  4 2017 21:39:34 --
tester 1ffffffff
tester 200000000

1 warning:

use of C99 long long integer constant [-Wlong-long

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

Thanks for the reply.

 

Please find attached screenshots. I have written same test code as told by you. Plz go through screenshots. But i am not getting the desired results.

 

Thanks,

Warm Regards,

Nilesh.

Attachment(s): 

Nilesh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In ASF  Choose new example project, then choose the Getting Started Example.

 

Insert the code I showed in the appropriate places.

 

Using Atmel Studio 7.0.1417

Last Edited: Mon. Aug 7, 2017 - 08:16 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

Thanks for the reply.

 

I tested other way. uint64_t working well. i.e. I had split this 64 bit as byte wise and transmitted over debug serial port it worked that means uint64_t is working with warning message. 

 

Looks like there is problem in printf. As I have configured stdio serial port as debug port. Seems like printf is not allowing to print uint64_t data type variables similarly printf doesn't allow float to print.

 

Can you suggest the changes to be done, so that printf will start allowing uint64_t data types?

 

Also I have posted one more message for UART receive callback related. But I am yet waiting for reply?

 

Thanks,

Warm Regards,

Nilesh

Nilesh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By default with the standard setup printf prints long long, as I showed you.

 

If you search for printing floats, that also works, but needs some changes in the routine used.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is some code showing printf, printing floats.

 

	while (1)
	{
		sum = 0.0;

		for (int i = 0;i<10000;i++)
		{
			aa[i] = (float)(rand() / (double)RAND_MAX);
			bb[i] = (float)(rand() / (double)RAND_MAX);
		}
		printf("start\r\n");
		stime = g_ul_ms_ticks;
		for (int i = 0;i<10000;i++)
		{
			cc[i] = aa[i] + bb[i];
		}
		etime = g_ul_ms_ticks;
		ttime = etime - stime;
		printf("end %u\r\n",ttime);
		for (int i = 0;i<10000;i++)
		{
			sum = sum + cc[i];
		}
		printf("sum is %e\r\n",sum);
		mdelay(100000);
	}

Here is the result:

 

-- Getting Started Example FPU test --  (I added FPU test).
-- SAME70-XPLD --
-- Compiled: Apr 15 2017 12:41:14 --

start
end 38
sum is 9.919035e+03
start
end 38
sum is 9.863185e+03
start
end 38
sum is 9.995521e+03
start
end 38
sum is 9.988999e+03
start
end 38
sum is 1.008262e+04
start
end 38
sum is 1.003994e+04
start
end 38

 

Last Edited: Mon. Aug 7, 2017 - 01:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I found the reference for printing floats, but it was for the E70 - V71 cortexM7

Last Edited: Mon. Aug 7, 2017 - 01:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is the note from Microchip (Atmel) support:

 

Question

How do you use printf with long long data type in ARM GCC compiler?

Answer
By default, Atmel Studio uses a size-optimized version of libc (newlib-nano).
One of the optimization in this library is to remove printf support for 64-bit wide variables. 

To switch the base version of libc (newlib) for adding the long long data type support to the printf library in Atmel Studio project, do the following:

  1. Open the project properties in Atmel Studio 
  2. Go to Miscellaneous in Toolchain -> ARM/GNU Linker
  3. Uncheck "Use size optimized library (--specs=nano.specs)"
  4. Rebuild the project 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is the code, modified from SamC21 Getting Started Application.  nano.specs unchecked. the warning -Wlong long removed.

 

#include "asf.h"
#include "stdio_serial.h"
#include "conf_uart_serial.h"
#define STRING_EOL    "\r"
#define STRING_HEADER "-- Getting Started Example Modified printf uint64--\r\n" \
		"-- "BOARD_NAME" --\r\n" \
		"-- Compiled: "__DATE__" "__TIME__" --\r\n" \
		"-- Prints uint64 --"STRING_EOL
static struct usart_module cdc_uart_module;
/**
 *  Configure UART console.
 */
static void configure_console(void)
{
	struct usart_config usart_conf;

	usart_get_config_defaults(&usart_conf);
	usart_conf.mux_setting = CONF_STDIO_MUX_SETTING;
	usart_conf.pinmux_pad0 = CONF_STDIO_PINMUX_PAD0;
	usart_conf.pinmux_pad1 = CONF_STDIO_PINMUX_PAD1;
	usart_conf.pinmux_pad2 = CONF_STDIO_PINMUX_PAD2;
	usart_conf.pinmux_pad3 = CONF_STDIO_PINMUX_PAD3;
	usart_conf.baudrate    = CONF_STDIO_BAUDRATE;

	stdio_serial_init(&cdc_uart_module, CONF_STDIO_USART_MODULE, &usart_conf);
	usart_enable(&cdc_uart_module);
}

int main(void)
{
	uint64_t tester;
	system_init();
	configure_console();
	delay_init();
	puts(STRING_HEADER);
	system_interrupt_enable_global();
	/*main loop*/
	while(1)
	{
		tester = 0x1FFFFFFFFFFllu;
		printf("tester = %llx\r\n",tester);
		tester++;
		printf("tester = %llx\r\n",tester);
		delay_s(4);
	}
	;
}

Results:

-- Getting Started Example Modified printf uint64--
-- SAMC21_XPLAINED_PRO --
-- Compiled: Aug  8 2017 07:09:25 --
-- Prints uint64 --
tester = 1ffffffffff
tester = 20000000000
tester = 1ffffffffff
tester = 20000000000
tester = 1ffffffffff
tester = 20000000000

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Microchip support also has a note about printing floats.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Microchip support comment about printing floats:

 

Question

How to use printf with software floating point in the Atmel ARM GNU Toolchain in Atmel Studio project?

Answer

To add the software floating point support to the printf library in Atmel Studio 6 project, do the following:

  1. Open the project properties in Atmel Studio 6
  2. Go to Miscellaneous in Toolchain -> ARM/GNU Linker
  3. Add --specs=nano.specs -lc -u _printf_float in the linker flags
  4. Rebuild the project 

 

The software floating point support for printf library was not available with the earlier versions of Atmel ARM GNU Toolchain. Atmel ARM GNU Toolchain version 4.7.3.158 or later is required for using printf with software floating point support. To update the Toolchain, please download ARM Toolchain update from Extension Manager in Atmel Studio. To update the Atmel Studio (ARM GNU Toolchain update is a part of it) to the latest version, please download from www.atmel.com/tools/atmelstudio....

 

I modified the above SamC21 program and added " -lc -u _printf_float" to the linker misc. section.

 

Here is the modified main

 

int main(void)
{
	uint64_t tester;
	float floater;
	system_init();
	configure_console();
	delay_init();
	puts(STRING_HEADER);
	system_interrupt_enable_global();
	/*main loop*/
	floater = 5.0;
	while(1)
	{
		tester = 0x1FFFFFFFFFFllu;
		printf("tester = %llx\r\n",tester);
		tester++;
		printf("tester = %llx\r\n",tester);
		floater = floater + 4.5;
		printf("floater = %f\r\n",floater);
		delay_s(4);
	}
	;
}

Result is:

 

-- Getting Started Example Modified printf uint64--
-- SAMC21_XPLAINED_PRO --
-- Compiled: Aug  8 2017 09:15:25 --
-- Prints uint64 --
tester = 1ffffffffff
tester = 20000000000
floater = 9.500000
tester = 1ffffffffff
tester = 20000000000
floater = 14.000000