Pages: [1] 2   Go Down
Author Topic: pgmspace.h is not supported?  (Read 7420 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino DUE rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm getting errors of file not found for this code:

#include <avr/pgmspace.h>

Or the folder \hardware\tools\avr\avr\include\avr where the file exists is not included on the search path for load?

« Last Edit: October 27, 2012, 07:07:29 pm by Baltasar » Logged

Check all my projects based on Atmel/Arduino -> www.aqualed-light.com

Offline Offline
Jr. Member
**
Karma: 9
Posts: 75
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

maple has  __FLASH__, e.g.,
uint32_t array[] __FLASH__ = {0, 1, 2};
  but that doesn't seem to work for DUE gcc. smiley-sad

But another thread in this Due forum notes that declaring things "const" puts them in flash ...  smiley
« Last Edit: October 27, 2012, 07:01:06 pm by mantoui » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino DUE rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a way to add some other directory to the lib global search path?

It works if I put the all directory to the file like this:

#include <C:\arduino-1.5\hardware\tools\avr\avr\include\avr\pgmspace.h>


So this must be a missing search path to the directory where these files are normaly like on previous IDE.

Logged

Check all my projects based on Atmel/Arduino -> www.aqualed-light.com

Leeds, UK
Offline Offline
Edison Member
*
Karma: 72
Posts: 1642
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, you don't need pgmspace any more. The Due and other arduinos are of different architecture, and with the due simply declaring const will put it in the program space.

This is what I have put at the top of one of my library files to make the two compatible:

Code:
#ifndef __arm__
#include <avr/pgmspace.h>
#else
#define PROGMEM const
#define F(x) x
#endif

And then for example you can use it like:

Code:
PROGMEM byte myArray[500] = {1,2,3,4,5,6, ...};


The advantage of doing it this way is that when you are using an avr, the #include statement will be valid.
Logged

~Tom~

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6381
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
#include <C:\arduino-1.5\hardware\tools\avr\avr\include\avr\pgmspace.h>
including an avr-specific include file (anything starting with "avr/" in an ARM project would be an extremely bad idea!

It would be nice if there were an Arduino "flashmem.h" or something that would hide some ugly conditional compilation similar to what Tom has done.

Logged

0
Offline Offline
God Member
*****
Karma: 24
Posts: 587
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the "pgmspace.h" that Teensy 3.0 uses to (hopefully) make most AVR-specific code compile and work:

Code:
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1

#include <inttypes.h>

#define PROGMEM
#define PGM_P  const char *
#define PSTR(str) (str)

typedef void prog_void;
typedef char prog_char;
typedef unsigned char prog_uchar;
typedef int8_t prog_int8_t;
typedef uint8_t prog_uint8_t;
typedef int16_t prog_int16_t;
typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;

#define strcpy_P(dest, src) strcpy((dest), (src))
#define strcat_P(dest, src) strcat((dest), (src))
#define strcmp_P(a, b) strcmp((a), (b))

#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
#define pgm_read_float(addr) (*(const float *)(addr))

#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
#define pgm_read_float_near(addr) pgm_read_float(addr)
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
#define pgm_read_word_far(addr) pgm_read_word(addr)
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
#define pgm_read_float_far(addr) pgm_read_float(addr)

#endif


I'm still refining this and lots of other AVR compatibility stuff.  But so far, it seems to be working for the most common usages.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 72
Posts: 1642
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That works well if you put it in the folder:
Code:
<Arduino Dir>\hardware\arduino\sam\libraries\avr\avr\

One query though, aren't you missing the const keyword? In which case surely everything gets stuck in the RAM, or have I missed something.

In which case should you define 'PROGMEM' as 'const'
#define PROGMEM const
I suppose the problem with that is if people put the PROGMEM term after the variable name in which case it wont work.
Logged

~Tom~

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino DUE rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Paul, including your code for now stoped givving errors regarding pgmspace but let's see further down since now I'm stucked on the port conversion, the lib referes to PORTA for example witch is not defined for DUO and I can't find where the new definitions exist or what I can use insted.


Tom, for now I just put the pgmspace.h file from Paul on the current lib dir and all previous #include <avr/pgmspace.h> I change them to #include "pgmspace.h".



Logged

Check all my projects based on Atmel/Arduino -> www.aqualed-light.com

0
Offline Offline
God Member
*****
Karma: 24
Posts: 587
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You mention "the lib".  What is that?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino DUE rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's the library I'm trying to port, actualy it's the UTFT from Henning Karlsen so I can use the TFT and touch with the DUO.
Logged

Check all my projects based on Atmel/Arduino -> www.aqualed-light.com

Leeds, UK
Offline Offline
Edison Member
*
Karma: 72
Posts: 1642
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you put it in the folder I suggested, you can just use:

#include <avr/pgmspace.h>
 
to include it in your library, meaning you can use the same stement for both due and avr.
« Last Edit: October 30, 2012, 04:11:30 am by Tom Carpenter » Logged

~Tom~

0
Offline Offline
God Member
*****
Karma: 24
Posts: 587
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's the library I'm trying to port, actualy it's the UTFT from Henning Karlsen so I can use the TFT and touch with the DUO.

Where could I buy a display that is known to work with UTFT using the serial interface?  I found the UTFT page and clicked links to the displays claimed to work.  All were out of stock, or 16 bit parallel interface, or had no significant info.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino DUE rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Paul, usualy I get them from here: http://imall.iteadstudio.com/display/tft-lcm.html but the sometimes show up on eBay.

I think all of them from taht link work with Henning library, I use the ITDB02-3.2WD.


Do you know where I can find info reagardin the DUO ports, since now I have to change all of that part of the code for the reconizes DUO ports, like for example this part:

Code:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
PORTA = VH;
pulse_low(P_WR, B_WR);
PORTA = VL;
pulse_low(P_WR, B_WR);
#else
PORTD = VH;
pulse_low(P_WR, B_WR);
PORTD = VL;
pulse_low(P_WR, B_WR);
#endif


PORTA and the rest are not beeing reconized since probably they are not defined.
Logged

Check all my projects based on Atmel/Arduino -> www.aqualed-light.com

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino DUE rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry Paul, I just realised now that you wore refering to the serial ones, those I don't really know.  smiley-confuse
Logged

Check all my projects based on Atmel/Arduino -> www.aqualed-light.com

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

While struggling with port definition, theres a file called variant.cpp that as the pin NAMES.

However, when trying to set the port with this:

      //DB08 on PIN22
      PIO_PB26=(VH & 0x01);

it returns:

D:\Docs\Arduino\arduino-1.5\libraries\UTFT\/HW_ARM.h:67: error: lvalue required as left operand of assignment

Line 67 is :

      PIO_PB26=(VH & 0x01);

Why is this happening? why can't I set this port bit with the LSB bit value of VH ?
Logged


Pages: [1] 2   Go Up
Jump to: