“Connection between the software code written and hardware resource use in the a

Hello All,

I come from a hardware background and I have started to use Arduino recently.
I was wondering how do I make the connection between the hardware resources that are used in my microcontroller and the software code I write.

Is there any good tutorial that anyone can advice?

Many Thanks,
Cserge.

I don't understand that question. All coding basically makes connections between hardware and software. Try any of the examples in the IDE.

For example, the Blink program connects the code to the LED which blinks.

Maybe the slightly longer code in planning and implementing a program would be interesting.

...R

cserge:
Is there any good tutorial that anyone can advice?

http://arduino.cc/en/Tutorial/HomePage

http://playground.arduino.cc/

Hello Nick,

First I want to thank you for taking your time to pick this question. Let me explain my question.
In Hardware description language (HDL) when I write.

Always@(posedge clk)
Q <= d ;

I know that a flip flop will be instantiated and that at every rising edge of the clock q will take the value of d. The code is above and what it creates in the FPGA chip is a Flip Flop.

When I write
Always@(a or b)
C = a & b ;

I know that an "and" gate will be instantiated in the hardware as a result of the code. Any change in a or b will update c.

That was the question.

I came to ask this question because I have two GSM shield.

One antenova Arduino GSM shield and SIM900 from ITEAD.

When I use the Arduino board I can still use my hyperterminal but when I use the SIM900 from ITEAD the Hyperterminal can no longer be used because the GSM900 is using those resources.

So my question was, how do I know by reading the C++ library in my program which hardware resources of the Microcontroller will be used? Is there any tutorial?

Many Thanks,
Cserge

Hello Nick,

I had also post somewhere else something that directly concern your web site and this was the question.
Any help will be appreciated.

===================================================

Hello all,

I have recently bought the GPS Shield at the link below:

http://imall.iteadstudio.com/im120417017.html

The GPS has an IIC and a SPI interface; I want to retrieve data from the GPS using IIC or SPI.

In my research, I have seen the beautiful website of Dr Nick Gammon at the link below

He presents a case where an Arduino is connected to a Memory. The example has for title:
"Example of I2C to access EEPROM".

Do you know how did he find out that the EEPROM address was 0x50? Can someone elaborate? In my understanding it is because by default line 8 and 5 are at one. Am I correct?

How do I give an address to the GPS? has anybody done a similar work before? Any code that can help me to start will be appreciated

I am using an Arduino MEGA2560.

Any input will be appreciated.

Kind Regards,
Cserge

===========================================================

I2C devices have addresses that are defined in the device data sheet. For that reason and many others, it is essential to download and consult the correct data sheet.

I have looked at the documents and I don't think that the GPS will communicate with I2C or SPI. UART only. The I2C and SPI signals are fed through the shield, but not used for communicating with the GPS. My GPS (Neo6M) is set up with a software serial port and I use TinyGPS to parse sentences.

cserge:
has anybody done a similar work before?

Nope, I don't think so.
You must be the first man in the world who is using a GPS module! :roll_eyes:

cserge:
Any code that can help me to start will be appreciated

I am using an Arduino MEGA2560.

GPS modules are operated via serial connections.

"Serial" in your Arduino is the serial connection between your Arduino board and the "serial monitor" on your PC.

If you have a board with more than one Serial port like the MEGA (which has four of them), you can use one of the extra serial ports to communicate with the GPS module and Serial to communicate with the PC.

Test sketch for Arduino MEGA:

// test sketch for GPS module and Arduino-MEGA
void setup()  
{
  Serial.begin(38400);  // this is the connection from Arduino to the serial monitor
  Serial.println("Goodnight moon!");
  Serial3.begin(9600);  // this is the connection from Arduino to the GPS module
}

void loop()  
{
  while(Serial3.available())
    Serial.write(Serial3.read());
}

Connect like this for loopback test:
Arduino GND ==> GPS module GND
Arduino 5V ==> GPS module 5V (if it is a 5V operated module)
Arduino RX3 ==> GPS module TX
Upload sketch, then open the serial monitor.
RX3 is pin 15 on the MEGA

If the sketch doesn't work, please make sure that you have set the serial monitor to 38400 baud and that your GPS module uses 9600 baud as the default baudrate. If your GPS module has different baudrate, change the baudrate for the GPS module in the sketch.

cserge:
I know that a flip flop will be instantiated and that at every rising edge of the clock q will take the value of d. The code is above and what it creates in the FPGA chip is a Flip Flop.

When I write
Always@(a or b)
C = a & b ;

I know that an "and" gate will be instantiated in the hardware as a result of the code. Any change in a or b will update c.

That was the question.

You don't need to know that. It is like asking which transistor inside your TV is used when you change channels.

I suggest doing some of the tutorials. Coding is not as complex as knowing which "and" gate in the processor does what.

Hello Nick and all,

I want to stop 5 minutes and say thank you enormously to all of you for your amazing feedback.
Actually you have a little bit reply to my question: "In Arduino programming language" you say

“Even a simple array like the one below uses 2000 Bytes of memory, this line alone would almost certainly make your program crash”

Int myData [20][50] ;

You said that too much SRAM will be used because of that line of code.You also said, do not use String it also takes too much SRAM.

So my question was, how can I learn these things myself?

Where can I go and check the amount of SRAM my code used ?

Now to reply to your statement

“You don't need to know that. It is like asking which transistor inside your TV is used when you change channels.”

My question would not have been which transistor inside your TV is used when you change channels, but rather was a transistor used or another resources?

I want to finish by repeating what I said in the beginning thank you enormously for your great work and for sharing your knowledge so kindly.

Cserge

Some things you learn from the datasheet of the hardware: '328P has 2K (2048) bytes of SRAM.
Some things you learn by reading, or experience: byte is 8 bits, int is 2 bytes, long is 4 bytes
int myData[20][50] is same as having 20 int long array, 50 times. So 20 int x 2 byte/int x 50 = 2000 bytes.

There is a freemem function you can call. I think the IDE might also report at compile time how much SRAM will be used by variables.

String, do some reading in the forum, watch all the complaints about String!

So my question was, how can I learn these things myself?

Google. Do the tutorial code that comes with the IDE. Look at some YouTube tutorials. Find an online book or resource about learning C. Practice what you learn.

Hello CrossRoad,

You are absolutely talking to my heart now. This is absolutely the spirit of my question.

I have research quickly your function “freemem” I could not find it. Although I appreciate the mathematical presentation, I cannot always sit down and check that for the entire variable that I used.

I have also verified that the IDE do not give the amount of SRAM used at compilation time.

So what do you suggest?

By the way, excuse my ignorance what difference does it make for the SRAM utilization if instead of using a String I used an array of char?

Thank you very much,
Cserge