igor 163 Posted August 19, 2014 Share Posted August 19, 2014 In the Energia port for the CC3200, will there be an avr/pgmspace.h replacement to help manage access to the program memory? If it is not already in the works, would such a thing be workable? As I understand it, the CC3200 stores program in an external memory, and loads it into RAM for execution. The AVR has two memory spaces (program and data), and on Arduino, avr/pgmspace.h defines various macros, etc. for using data in program space. Seems like it might be possible to create a pgmspace.h (and accompanying library) which would allow use of data stored in the CC3200 external memory in a way compatible with some Arduino libraries. Just a thought at this point, I have not studied the CC3200 architecture, and my familiarity with pgmspace.h is mostly in finding ways to work around it when porting AVR Arduino libraries to ARM. (Got started thinking about this because I was thinking it would be nice if Energia included a avr/pgmspace.h for MSP430 and for Tiva, similar to what TeensyDuino does. http://forum.stellarisiti.com/topic/1983-howto-porting-libraries-some-help-needed/?p=7660 ) Quote Link to post Share on other sites
energia 485 Posted August 19, 2014 Share Posted August 19, 2014 I was just working on this. Right now it is solved by adding the macro's to Energia.h as per patch below but it might be good to stick a dummy avr/pgmspace.h in Energia somewhere. --- a/hardware/msp430/cores/msp430/Energia.h +++ b/hardware/msp430/cores/msp430/Energia.h @@ -12,6 +12,13 @@ extern "C"{ #endif +#define PSTR +#define PROGMEM +#define pgm_read_byte(x) (*x) +#define pgm_read_dword(x) (*x) +#define strcat_P strcat +#define strlen_P strlen + #define NOT_A_PORT 0 #define NOT_A_PIN 0 #define NOT_ON_TIMER 0 igor 1 Quote Link to post Share on other sites
igor 163 Posted August 21, 2014 Author Share Posted August 21, 2014 Thanks. Couple of thoughts on the patch - in pgm_read_byte(x), should the replacement have parenthesis around x? Would it be prudent to check to be sure PROGMEM, etc. not already defined? (I expect that if the user already had a patch for dealing with PROGMEM it would usually be after Energia.h, so it is their problem to protect from duplicate definitions, but not sure if that will always be the case.) e.g. as below: extern "C"{ #endif #ifndef PSTR +#define PSTR #endif #ifndef PROGMEM +#define PROGMEM #endif // Add similar checks/protection to other progmem macros +#define pgm_read_byte(x) (*(x)) +#define pgm_read_dword(x) (*(x)) +#define strcat_P strcat +#define strlen_P strlen + #define NOT_A_PORT 0 #define NOT_A_PIN 0 #define NOT_ON_TIMER 0 Is there anything interesting/different that would be better on the CC3200? Quote Link to post Share on other sites
energia 485 Posted August 22, 2014 Share Posted August 22, 2014 That makes perfect sense @@igor. I just files a bug for it: https://github.com/energia/Energia/issues/455 Quote Link to post Share on other sites
igor 163 Posted November 9, 2014 Author Share Posted November 9, 2014 Better versions of pgm_read_byte: #define pgm_read_byte(x) (*(const unsigned char *)(x)) #define pgm_read_dword(x) (*(const unsigned long *)(x)) Quote Link to post Share on other sites
energia 485 Posted November 10, 2014 Share Posted November 10, 2014 The avr header files have been checked in. They come from the Arduino repo for the SAM micro controller: https://github.com/energia/Energia/commit/cafa204a33e6e0dfa65b2f97dd14792a5964837e This will be rolled into the next release. igor 1 Quote Link to post Share on other sites
amirchaudhary 0 Posted November 19, 2014 Share Posted November 19, 2014 I have interfaced accelerometer sensor using energia but not able to program the temperature sensor on CC3200 launchpad but not able to connect the compiler shows the following error C:\Program Files\energia-0101E0013\hardware\cc3200\libraries\Adafruit_TMP006\Adafruit_Sensor.cpp:2:26: fatal error: avr/pgmspace.h: No such file or directory compilation terminated. but this was solved wen i copied the adafruit library but again a new error C:\Program Files\energia-0101E0013\hardware\cc3200\libraries\Wire\utility\twi.c:25:20: fatal error: avr/io.h: No such file or directory compilation terminated. i am not able to solve it not getting any clue for it please guide!!!! Quote Link to post Share on other sites
BigG 1 Posted November 19, 2014 Share Posted November 19, 2014 I have interfaced accelerometer sensor using energia but not able to program the temperature sensor on CC3200 launchpad but not able to connect the compiler shows the following error C:\Program Files\energia-0101E0013\hardware\cc3200\libraries\Adafruit_TMP006\Adafruit_Sensor.cpp:2:26: fatal error: avr/pgmspace.h: No such file or directory compilation terminated. but this was solved wen i copied the adafruit library but again a new error C:\Program Files\energia-0101E0013\hardware\cc3200\libraries\Wire\utility\twi.c:25:20: fatal error: avr/io.h: No such file or directory compilation terminated. i am not able to solve it not getting any clue for it please guide!!!! I don't know the answer but I have come across other posts in the forum before about similar issues re temperature sensor... buried within this post (2 or more pages) may be some guidance... http://forum.43oh.com/topic/5839-new-energia-release-0101e0013-09052014/ http://forum.43oh.com/topic/5839-new-energia-release-0101e0013-09052014/page-2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.