_SFR_IO_ADDR() on Arduino Mega PortH+ - arduino

I tried to use the SoftI2CMaster library [http://playground.arduino.cc/Main/SoftwareI2CLibrary], the library works great in most cases, but it doesn't work on ports H through L, the compiler give me following message:
/SoftI2CMaster.h: In function 'boolean i2c_init()':
/SoftI2CMaster.h:265: error: impossible constraint in 'asm'
Basically the code that caused the problem is some assembly:
__asm__ __volatile__
(
...
: :
[SCLDDR] "I" (SCL_DDR), [SCLPIN] "I" (SCL_PIN),
[SCLIN] "I" (SCL_IN), [SCLOUT] "I" (SCL_OUT));
After some test, trial and error, I am pretty sure the problem is coming from SCL_DDR and those related variables, here's how they defined:
#define SDA_DDR (_SFR_IO_ADDR(SDA_PORT) - 1)
#define SCL_DDR (_SFR_IO_ADDR(SCL_PORT) - 1)
#define SDA_OUT _SFR_IO_ADDR(SDA_PORT)
#define SCL_OUT _SFR_IO_ADDR(SCL_PORT)
#define SDA_IN (_SFR_IO_ADDR(SDA_PORT) - 2)
#define SCL_IN (_SFR_IO_ADDR(SCL_PORT) - 2)
For the SXX_PORT, if I supply anything PORTA-PORTG will be fine, program compiles and execute without issue, but then if I supply PORTH-PORTK the error will come out. Can anyone point out what's the problem? Is the problem from _SFR_IO_ADDR()?

The constraint "I" requires a constant from 0 to 63. If you choose one of the higher ports, then the address (_SFR_IO_ADDR()) will be higher than 63.
You could try changing the modifier to "M", which requires a constant fitting in 8 bits. I don't know if this will work, or why the author chose to use "I".
If it works, you could send the author a bug report.

Related

EspSoftwareSerial with ESP8266: error no matching function for call to 'SoftwareSerial::SoftwareSerial()'

i am trying to program with Arduino IDE 1.8.13 using EspSoftwareSerial library (target ESP8266).
Whatever example provided that I try to compile, I get an error (for example for the program "servoTester") :
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
SoftwareSerial swSer;
...
servoTester:4:16: error: no matching function for call to 'SoftwareSerial::SoftwareSerial()'
SoftwareSerial swSer;
I am not familiar with C ++ and Arduino (but I know C well on microcontrollers).
I'm a little bored, I've searched all over the place for solutions, and feel like I'm not the only one having this problem, but I haven't found a solution that works.
I tried to :
change the <> by ""
restart Arduino after installing the EspSoftwareSerial library
Reinstall Arduino
and various absurd things %-(
Does somebody have an idea ?

Model non-deterministic value integer in Frama-C

Could anyone please tell me is this the right model for non-deterministic values of integer and unsigned integer in Frama-C?
/* Suppose Frama-C is installed in /usr/local -default prefix */
#include "/usr/local/share/frama-c/builtin.h"
#include "/usr/local/share/frama-c/libc/limits.h"
...
#define nondet_int() Frama_C_interval(INT_MIN, INT_MAX)
#define nondet_uint() Frama_C_interval(0, UINT_MAX)
...
Are there any exceptions if I use the above code with different architectures in option -machdep?
No, in the Neon version you have to manually define the appropriate macro if you want to use another -machdep. You would typically end up with a command-line like that:
frama-c -cpp-extra-args="-D__FC_MACHDEP_X86_64" -machdep x86_64
Forthcoming Sodium release will make the -cpp-extra-args unnecessary, as well as providing by default a -I option to let preprocessor search into Frama-C's libc header, so that you won't have to provide it yourself or rely on absolute paths in your #include directive
NB: This answer is not a commitment to any particular date for the Sodium release.
One reason Frama_C_interval(0, UINT_MAX) may not work as intended is that Frama_C_interval has type int (int, int). When you happen to want the entire range of unsigned int values, that actually tends to help because the conversions that are introduced are subject to approximation, but in general the fact that Frama_C_interval is declared as returning an int is a nuisance.
The latest released version already has Frama_C_unsigned_int_interval, but it is in share/libc/__fc_builtin.h (installed to /usr/local/share/frama-c/libc/__fc_builtin.h. The file builtin.h looks like a vestigial remnant, especially with the $Id$ line dating back to when development was done under SVN.
For specifying that a value should be all possible unsigned intvalues, Frama_C_unsigned_int_interval(0, -1) saves yourself the trouble of including limit.h. The int value -1 passed as argument is converted to the largest unsigned int as per C rules.

Coding errors between the Arduino Uno and SDI-12 interface on Decagon Devices

I have been working on a project recently using a sensor for electrical conductivity in soil (A 5TE sensor from Decagon Devices) with my Arduino Uno. I am ready to code, and found this example code on GitHub (the example code is there when you scroll down the page). When trying to run it on the latest version of Arduino, it gave me these compilation errors:
sketch_dec15a:7: error: expected initializer before 'void'
sketch_dec15a:4: error: 'SDISerial' does not name a type
sketch_dec15a:9: error: expected initializer before 'void'
sketch_dec15a.ino: In function 'void loop()':
sketch_dec15a:22: error: 'connection' was not declared in this scope
NOTE: I believe I installed the library correctly, but am not 100% certain...more like 85%.
What's wrong with the code and how can it be made to work?
The example code is wrong. Look at the compilation errors. The first thing it says is:
sketch_dec15a:7: error: expected initializer before 'void'
So what it's saying is that it found something that said void and expected to see something else first. void occurs only twice in your code, so we can't be far. Let's take a look at the code immediately surrounding it the first void:
char tmp_buffer[4];
char sensor_info[]
//initialize variables
void setup(){
connection.begin();
Serial.begin(9600);//so we can print to standard uart
//small delay to let the sensor do its startup stuff
delay(3000);//3 seconds should be more than enough
}
Right before the void setup(){ is //initialize variables. That's just a comment, and not code, so it doesn't relly count. Looking back one more line we see:
char sensor_info[]
Something is wrong with that line. Work on it and see if you can figure it out (check the other lines for "hints"). If you can't figure it out, the answer is right below (put your mouse over it to see it):
It needs a semicolon ";" at the end to complete the statement. Because the semicolon is missing, it thinks "void setup(){" is part of the previous statement.

warning undefined reference to arduino due in multiwii

I try to compile multiwii code on DUE https://github.com/HefnySco/MultiWii_DUE
I keep getting
C:\Users\MCA9A~1.HEF\AppData\Local\Temp\build4616066844745192383.tmp\EEPROM.cpp.o: In function eeprom_write_block(void*, void*, unsigned int)
C:\Users\MCA9A~1.HEF\AppData\Local\Temp\build4616066844745192383.tmp/Sensors.cpp:307: warning: undefined reference toWire'
I made a separate project to simulate the case and created file called class1.cpp and included Wire_DUE.h and then called it from the main project class Sample1.cpp and it worked using the very same Wire_DUE code.
Kindly advise
At last after 4 days I found the answer.
I used this in def.h
#if defined (__CM3_REV)
#define ARDUINO_DUE
#endif
and when I updated to this
#if defined (ARDUINO_ARCH_SAM)
#define ARDUINO_DUE
#endif
it works .... pls not that in both cases ARDUINO_DUE is defined .... but not sure what is the difference exactly as in both ways ARDUINO_DUE is active.... seems that in some .cpp files it is not active due to other declarations that conflict with __CM3_REV

Spartan 3 Starter Kit Constraints File

I am not sure if this is the right stack exchange website to post this on, but if it isn't please move it to the appropriate one.
I am facing a small problem in writing my constraints file for the spartan 3 starter kit.
I have read the documentation provided by Xilinx (the manufacturer) and ive been searching online for a few weeks without any luck.
What i am trying to do is link my Netlist interface to any of the 3 40-pin-headers on the board. (See image below)
Usually its very simple, if say i want to interface a button or a led on the board, i just read the connection name on the board, for example one of the buttons is M13 and write in the UCF file something like this :
NET "BTN0" LOC = "M13";
As you can see on the image the headers are named A1, A2 and B1 on the board, but oddly enough, none of the following worked :
NET "TestOutputLine" LOC = "A1(0)"; -- The (0) is to reference a single line on an array
NET "TestOutputBus" LOC = "A1"; -- The bus is of equal dimension of A1 (which is 40)
The errors i got meant that either the target (specified by LOC) does not exist or that the assignment is invalid.
I hope you have some ideas for me.
Thanks in advance
EDIT :
Here is the output from ISE :
ConstraintSystem:59 - Constraint <NET "TestOutputBus" LOC = "A1";>
[circuit.ucf(12)]: NET "TestOutputBus" not found. Please verify that:
1. The specified design element actually exists in the original design.
But i am pretty sure that TestOutputBus exists, as a matter of fact there is nothing else in my design right now, and the correct top level unit is being used.
EDIT2 :
I updated my UCF file, right now it's like this :
NET "TestOutputBus(0)" LOC = "A1(0)";
NET "TestOutputBus(1)" LOC = "A1(1)";
But i get a different error now in mapping :
MapLib:30 - LOC constraint A1:0 on TestOutputBus<0> is invalid: No such
site on the device. To bypass this error set the environment variable
'XIL_MAP_LOCWARN'.
MapLib:30 - LOC constraint A1:1 on TestOutputBus<1> is invalid: No such
site on the device. To bypass this error set the environment variable
'XIL_MAP_LOCWARN'.
Solution :
In order to get the pins 5 and 6 mapped to TestOutputBus(0) and TestOutputBus(1) respectively what i had to use was this :
NET "TestOutputBus(0)" LOC = "N7"; -- A1 pin 5
NET "TestOutputBus(1)" LOC = "L5"; -- A1 pin 6
Note that pins 0 are not mappable thats why i used pins 5 and 6, here are the tables that show the mappable pins for all headers and their LOCs.
As it turns out, there is an address for each usable pin of each header of the FPGA.
The datasheet (http://forums.xilinx.com/xlnx/attachments/xlnx/Spartan/3411/1/S3BOARD_RM.pdf) was helpful especially pages 49 - 51
I copied this from my earlier comment to your question so it would be an actual answer and not just a comment.
You should have LOC constraints in your UCF file for every port on your top-level module. So if you have a 40-bit-wide bus as an input or output at the top level then you should also have 40 separate LOC constraints in your UCF file to make sure that the logical bus in your top-level schematic actually gets mapped to the correct pins on your FPGA. If you are only using two pins, then you can declare the bus to be 2-bits wide and use 2 LOC constraints. The FPGA will treat all unused pins as inputs and ignore them.
I once got the original ConstraintSystem:59 net xyz not found error when i accidentally selected one of my modules as a top module. The pins declared in UCF could not be found in the port declaration of wrong module.
Also i get this error when i have some pin declared in UCF but ommit it in port declaration of top module.

Resources