chipKIT® Development Platform

Inspired by Arduino™

Unable to use Time.h

Created Tue, 21 Jun 2011 16:01:00 +0000 by abhijeet.k1810


abhijeet.k1810

Tue, 21 Jun 2011 16:01:00 +0000

I am unable to compile and use Time.h library for Max32, but the same file compiles fine for my Arduino. I am using Windows 7 x86 The Time.h Library can be found at

h,t,t,p,:,/,/,w,w,w,.,a,r,d,u,i,,n,o,.,c,c,/,p,l,a,y,g,r,o,u,n,d,/,C,o,d,e,/,T,i,m,e,

(please remove all the commas)

I am using their "TimeSerial" Example.....

First I was getting an error regarding avr/pgmspace.h not found and avr/io.h not found. Then I copied all the files inside the Avr directory to ~\mpide-0022-chipkit-win-20110521-c\hardware\pic32\compiler\pic32-tools\pic32mx\include
Inside the directory avr. Now I am getting the following eroors. Please help...

In file included from c:\users\abhijeet\documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/avr/pgmspace.h:82:0, from C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:10: c:\users\abhijeet\documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/avr/io.h:330:6: warning: #warning "device type not defined" C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:18:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:19:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:20:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:21:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:22:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:23:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:24:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:25:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:26:18: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:27:19: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:28:19: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:29:19: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:31:22: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:37:26: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:39:16: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:40:16: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:41:16: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:42:16: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:43:16: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:44:16: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:45:16: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:46:16: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:48:20: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:49:24: warning: 'progmem' attribute directive ignored C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp: In function 'char* monthStr(__uint8_t)': C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:55:29: error: cast from 'const prog_char**' to '__uint16_t' loses precision C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp: In function 'char* monthShortStr(__uint8_t)': C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:62:19: error: cast from 'char*' to '__uint16_t' loses precision C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp: In function 'char* dayStr(__uint8_t)': C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:69:28: error: cast from 'const prog_char**' to '__uint16_t' loses precision C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp: In function 'char* dayShortStr(__uint8_t)': C:\Users\ABHIJEET\Documents\mpide-0022-chipkit-win-20110521-c\hardware\pic32\libraries\Time\DateStrings.cpp:77:19: error: cast from 'char*' to '__uint16_t' loses precision


davec

Sat, 02 Jul 2011 00:26:33 +0000

First I was getting an error regarding avr/pgmspace.h not found and avr/io.h not found. Then I copied all the files inside the Avr directory to ~\mpide-0022-chipkit-win-20110521-c\hardware\pic32\compiler\pic32-tools\pic32mx\include
Inside the directory avr.

That's probably not a good idea, you should delete and reinstall the mpide distribution.

Attached is my attempt at a DateStrings.cpp port, which seems to work. The changes are probably a bit more extensive than they need to be, but I just wanted to get it working. Replace the DateStrings.cpp file in the Time library with this one and it should compile and run.


abhijeet.k1810

Mon, 04 Jul 2011 14:44:58 +0000

This did not work I am getting the error

C:\Users\Abhijeet\Desktop\mpide-0022-chipkit-win-20110521\hardware\pic32\libraries\Time\DateStrings.cpp:10:27: fatal error: avr/pgmspace.h: No such file or directory compilation terminated.

I downloaded fresh copy and unzipped it but still not working


abhijeet.k1810

Mon, 04 Jul 2011 14:48:26 +0000

Tell me the complete process. Starting from Adding the Library to MPIDE


Mark

Mon, 04 Jul 2011 15:00:41 +0000

Tell me the complete process. Starting from Adding the Library to MPIDE

The number one thing is to put ifdefs around the avr include instructions

#if defined(AVR) #include <avr/pgmspace.h> #endif

Then you can include

#include "wiring.h"

This has the necessary defines that are normally in pgmspace.h

I looked over the code briefly and this should do it. I will try to test it later

The proper place to put the library is in your local library folder

sketches-&gt;libraries

If you dont know where your sketches folder is, look in your MPIDE preferences, mine is /Arduino/sketches

Mark


davec

Mon, 04 Jul 2011 17:16:25 +0000

This did not work I am getting the error C:\Users\Abhijeet\Desktop\mpide-0022-chipkit-win-20110521\hardware\pic32\libraries\Time\DateStrings.cpp:10:27: fatal error: avr/pgmspace.h: No such file or directory compilation terminated. I downloaded fresh copy and unzipped it but still not working

You need to replace this file with the DateStrings.cpp from the above zip file:

C:\Users\Abhijeet\Desktop\mpide-0022-chipkit-win-20110521\hardware\pic32\libraries\Time\DateStrings.cpp

The error message is saying that it's trying to include avr/pgmspace.h from line 10 of DateStrings.cpp, but my version has "#if defined(AVR)" at line 10.


Mark

Mon, 04 Jul 2011 17:48:04 +0000

I have found a major problem with the compile process. There is a file called Time.h in the pix32 includes. I am working on modifying the files so they compile properly. We have created a new github repository just for 3rd party libraries

https://github.com/chipKIT32/thirdpartylibraries

I will try to get the time library all fixed and put it up on this github site

Mark


davec

Mon, 04 Jul 2011 19:03:51 +0000

I have found a major problem with the compile process. There is a file called Time.h in the pix32 includes.

I have several copies of "time.h" under pic32mx, but not a "Time.h"? I guess this could still cause problems under Windows. It works for me but possibly because I have the Time library installed in my personal libraries folder.


grimcomp

Fri, 20 Jan 2012 10:10:45 +0000

Hi davec, thanks for the DateStrings modifications. I installed it as per your instructions and the RTC example compiled and ran first time. I looked at the code but the C pointers put me off trying to change anything. We all how have a great time library for the Pic32.