Go Down

Topic: Arduino Due libraries (official and 3rd party) (Read 298290 times) previous topic - next topic

mtorruella

HI nitrof¡¡¡

I don't have any specific code error, I was working with arduino MEGA 2560 + SIM900 Shield, I did'nt have any problems with this platform, i was using GPRS_Shield_Arduino.h and did my life easier interfasing wiht SIM900, I did not have to use AT commands.

I had some issues with MEGA sdram capacity, then I have to move to the Arduino DUE, the GPRS_Shield_Arduino.h is not compatible with DUE, because of that, I am looking for a new library compatible with DUE how can help me interfasing with SIM900 without the need to use AT commands.

Thanks for your help¡¡¡¡

antodom

HI

I am using and arduino due with SIM900 Shield and i am having problem with GPRS_Shield_Arduino.h and SofwareSerial.h library, seem is not compatible with due, there are a solution for use SIM900 shield with due?

Thanks in advance
Hi there @mtorruella,

Using SoftwareSerial with the DUE is not possible, this is a library which is not compatible with Arduino DUE's ATSAM3X8E microcontroller. As an alternative you should use any of the hardware serial ports available in the DUE, or the software serial library for the DUE soft_uart, available at https://github.com/antodom/soft_uart.

I hope it helps.
------------
antodom

mtorruella

Hi antodom

I will try with soft_uart Thanks!!!!!

hasanturgut

Hello there,
I have a program that I run with mega. I can't run this program with DUE. When I load the Nextion screen library it gives an error in compilation. what is the solution to this.

error message;

Arduino:1.8.12 (Windows 10), Kart:"Arduino Due (Programming Port)"
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:285:2: error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
 ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp: In member function 'bool SoftwareSerial::listen()':
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:341:23: error: 'SREG' was not declared in this scope
    uint8_t oldSREG = SREG;
                      ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:342:9: error: 'cli' was not declared in this scope
    cli();
        ^
In file included from C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\cores\arduino/Arduino.h:201:0,
                from C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:43:

C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setTX(uint8_t)':
C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\variants\arduino_due_x/variant.h:63:65: error: invalid conversion from 'Pio*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P)        ( g_APinDescription[P].pPort )
                                                                ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:517:18: note: in expansion of macro 'digitalPinToPort'
  uint8_t port = digitalPinToPort(tx);
                 ^
C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\variants\arduino_due_x/variant.h:66:44: error: base operand of '->' is not a pointer
#define portOutputRegister(port)   ( &(port->PIO_ODSR) )
                                           ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:518:27: note: in expansion of macro 'portOutputRegister'
  _transmitPortRegister = portOutputRegister(port);
                          ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setRX(uint8_t)':

C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\variants\arduino_due_x/variant.h:63:65: error: invalid conversion from 'Pio*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P)        ( g_APinDescription[P].pPort )
                                                                ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:528:18: note: in expansion of macro 'digitalPinToPort'
  uint8_t port = digitalPinToPort(rx);
                 ^
C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\variants\arduino_due_x/variant.h:67:44: error: base operand of '->' is not a pointer
#define portInputRegister(port)    ( &(port->PIO_PDSR) )
                                           ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:529:26: note: in expansion of macro 'portInputRegister'
  _receivePortRegister = portInputRegister(port);
                         ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':

C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:540:31: error: 'table' was not declared in this scope
  for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)
                             ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:556:38: error: 'digitalPinToPCICR' was not declared in this scope
    if (digitalPinToPCICR(_receivePin))
                                     ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:558:78: error: 'digitalPinToPCICRbit' was not declared in this scope
      *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
                                                                             ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:558:79: error: '_BV' was not declared in this scope
      *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
                                                                              ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:559:37: error: 'digitalPinToPCMSK' was not declared in this scope
      *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
                                    ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:559:78: error: 'digitalPinToPCMSKbit' was not declared in this scope
      *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
                                                                             ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:574:36: error: 'digitalPinToPCMSK' was not declared in this scope
  if (digitalPinToPCMSK(_receivePin))
                                   ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:575:77: error: 'digitalPinToPCMSKbit' was not declared in this scope
    *digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
                                                                            ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:575:78: error: '_BV' was not declared in this scope
    *digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
                                                                             ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp: In member function 'virtual size_t SoftwareSerial::write(uint8_t)':
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:610:21: error: 'SREG' was not declared in this scope

  uint8_t oldSREG = SREG;
                    ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:611:7: error: 'cli' was not declared in this scope
  cli();  // turn off interrupts for a clean txmit
      ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:615:26: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope
  tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);
                         ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp: In member function 'virtual void SoftwareSerial::flush()':

C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:658:21: error: 'SREG' was not declared in this scope

  uint8_t oldSREG = SREG;
                    ^
C:\Users\User\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:659:7: error: 'cli' was not declared in this scope
  cli();
      ^
exit status 1
Arduino Due (Programming Port) kartı için derleme hatası.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


nitrof

Hi hasanturgut.

First, you should have start a new tread for your question.
second, put any code or error text into code brace ( look up the </> )
Third, you should also post any code you have.

By now, I can tell that softwareSerial do not support DUE.


Whit DUE, you can use build in serial port without using softwareSerial. just use Serial1 to 3.


But again, without code, can't tell more.

Regards.

Nitrof

steveit

Hi Antodom,
I'm trying to use your soft_uart library and am having a problem. I have a data logging program which logs data from various sensors, and am trying to use a soft serial to send some data back to a PC for testing purposes. I based the code for the soft_uart on one of the examples supplied.

After the serial declaration section:

#include "soft_uart.h"
using namespace soft_uart;
using namespace soft_uart::arduino_due;

#define RX_PIN 53 // software serial port's reception pin
#define TX_PIN 51 // software serial port's transmision pin
#define SOFT_UART_BIT_RATE 57600 // 57600 38400 1200 19200 9600 115200 300
#define RX_BUF_LENGTH 16 // software serial port's reception buffer length
#define TX_BUF_LENGTH 64 // software serial port's transmision buffer length

// declaration of software serial port object serial_tc4
// which uses timer/counter channel TC4
serial_tc4_declaration(RX_BUF_LENGTH,TX_BUF_LENGTH);
auto& serial_con=serial_tc4; // serial_tc4_t& serial_obj=serial_tc4;  Serial Console


which is straight from the example, I have:

#define NUM_TRS 4
typedef struct {
  char data[NUM_TRS][8];
  HardwareSerial *serial[NUM_TRS];
} tr_sense;
tr_sense tRange;


then further down the code I decalare a function:

int LogData(tr_sense *data, double temp, double temp2) {
 ...
}

The compiler complains that 'tr_sense was not declared in this scope'.

If I comment out the soft_uart declaration lines:

//serial_tc4_declaration(RX_BUF_LENGTH,TX_BUF_LENGTH);
//auto& serial_con=serial_tc4; // serial_tc4_t& serial_obj=serial_tc4;  Serial Console


everything comiles and works ok, obviously without soft_uart functionality. I'm a bit lost at this point. Please help...

Thank you for writing the library anyway, especially if I can get it to work in my code :)

steveit

Apologies, but my last post on difficulties on using the soft_uart library, didn't supply information on what board I was trying to use.

I am using the Arduino DUE board.

I have tried searching the forum on this error but didn't find anything relevant to this specific situation.


antodom

HI there @steveit,

I would need  to have a look to your whole example and the compiler output for being of any help.

Best regards.
------------
antodom

steveit

Hi Antodom,

Pretty much what you saw in the post will reproduce the issue:
Code: [Select]
#include "soft_uart.h"
using namespace soft_uart;
using namespace soft_uart::arduino_due;

#define RX_PIN 53 // software serial port's reception pin
#define TX_PIN 51 // software serial port's transmision pin
#define SOFT_UART_BIT_RATE 57600 // 57600 38400 1200 19200 9600 115200 300
#define RX_BUF_LENGTH 16 // software serial port's reception buffer length
#define TX_BUF_LENGTH 64 // software serial port's transmision buffer length

// declaration of software serial port object serial_tc4
// which uses timer/counter channel TC4
serial_tc4_declaration(RX_BUF_LENGTH,TX_BUF_LENGTH);
auto& serial_con=serial_tc4; // serial_tc4_t& serial_obj=serial_tc4;  Serial Console




#define NUM_TRS 4
typedef struct {
  char data[NUM_TRS][8];
  //HardwareSerial *serial[NUM_TRS];
} tr_sense;
tr_sense tRange;

int LogData (tr_sense *data, double temp, double temp2) {
 return(0);
}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}


The program I have here as a whole has a lot more code in it to read sensors from the 4 hardware serial ports, a couple of SPI sensors and an IIC RTC, but this basic framework code will reporoduce the issue.

The compiler output is:
Code: [Select]



soft_uart_test:26: error: 'tr_sense' was not declared in this scope

 int LogData (tr_sense *data, double temp, double temp2) {

             ^

soft_uart_test:26: error: 'data' was not declared in this scope

 int LogData (tr_sense *data, double temp, double temp2) {

                       ^

soft_uart_test:26: error: expected primary-expression before 'double'

 int LogData (tr_sense *data, double temp, double temp2) {

                             ^

soft_uart_test:26: error: expected primary-expression before 'double'

 int LogData (tr_sense *data, double temp, double temp2) {

                                          ^

soft_uart_test:26: error: expression list treated as compound expression in initializer [-fpermissive]

 int LogData (tr_sense *data, double temp, double temp2) {

                                                      ^

C:\Users\S.Bassett\Documents\Arduino\soft_uart_test\soft_uart_test.ino: In function 'int LogData(tr_sense*, double, double)':

soft_uart_test:26: error: 'int LogData(tr_sense*, double, double)' redeclared as different kind of symbol

 int LogData (tr_sense *data, double temp, double temp2) {

                                                       ^

soft_uart_test:26: error: previous declaration of 'int LogData'

 int LogData (tr_sense *data, double temp, double temp2) {

     ^

exit status 1
'tr_sense' was not declared in this scope


Where is says "soft_uart_test:26: error: previous declaration of 'int LogData'", no matter what name I give the function it gives this output with the new name.

Thanks for your reply

antodom

Hi there again @steveit,

I suspect the Arduino IDE is seeing the prototype of function logData() before seeing the struct definition. Try if including struct tr_sense definition before the definition of soft_uart objects solve the problem.

Best.
------------
antodom

nitrof

try not typedef it:


Code: [Select]

struct tr_sense{
  char data[NUM_TRS][8];
  //HardwareSerial *serial[NUM_TRS];
};

tr_sense tRange;

steveit

Hi Antodom,

That got rid of the error, thank you. I've been shoved in the deep end with this project, as a software developer from a couple of decades ago and out of practice.

Also thanks for the reply from nitrof, something else to bear in mind.

Thanks again.

Go Up