Difference between revisions of "Arduino notes"

From Wiki at Neela Nurseries
Jump to: navigation, search
m
 
(6 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
  
Getting started . . .
+
Getting started:
  
 
*  https://playground.arduino.cc/Learning/CommandLine . . . mentions PlatformIO "ecosystem" and specific Linux ready command line tools for working with Arduino
 
*  https://playground.arduino.cc/Learning/CommandLine . . . mentions PlatformIO "ecosystem" and specific Linux ready command line tools for working with Arduino
Line 9: Line 9:
 
*  https://www.youtube.com/watch?v=qAM2S27FWAI . . . avr-dude and related tools can program Arduino Uno boards
 
*  https://www.youtube.com/watch?v=qAM2S27FWAI . . . avr-dude and related tools can program Arduino Uno boards
  
 +
*  https://playground.arduino.cc/OpenBSD/CLI . . . Arduino development work on OpenBSD systems
  
Specific Arduino projects . . .
+
 
 +
The ATMEGA328P processor used in Arduino Uno boards:
 +
 
 +
*  http://www.microchip.com/wwwproducts/en/ATmega328p . . . the ATMEGA328P processor used in Arduino Uno boards
 +
 
 +
 
 +
 
 +
Specific Arduino projects:
  
 
*  https://www.hackster.io/niesse/water-level-ultrasonic-sensor-with-lorawan-c2cf55
 
*  https://www.hackster.io/niesse/water-level-ultrasonic-sensor-with-lorawan-c2cf55
 +
*  https://www.arduino.cc/en/Tutorial/HelloWorld
 +
 +
 +
FreeRTOS port to Arduino:
 +
 +
*  https://github.com/feilipu/Arduino_FreeRTOS_Library
 +
 +
 +
== Arduino Wire Library ==
 +
 +
2018-05-21 - Monday, looking at /usr/share/arduino/libraries/Wire/utility/twi.c, routine twi_writeTo() error codes:
 +
 +
<pre>
 +
177 /*
 +
178  * Function twi_writeTo
 +
179  * Desc    attempts to become twi bus master and write a
 +
180  *          series of bytes to a device on the bus
 +
181  * Input    address: 7bit i2c device address
 +
182  *          data: pointer to byte array
 +
183  *          length: number of bytes in array
 +
184  *          wait: boolean indicating to wait for write or not
 +
185  *          sendStop: boolean indicating whether or not to send a stop at the end
 +
186  * Output  0 .. success
 +
187  *          1 .. length to long for buffer
 +
188  *          2 .. address send, NACK received
 +
189  *          3 .. data send, NACK received
 +
190  *          4 .. other twi error (lost bus arbitration, bus error, ..)
 +
191  */
 +
192 uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop)
 +
193 {
 +
194  uint8_t i;
 +
195
 +
196  // ensure data will fit into buffer
 +
197  if(TWI_BUFFER_LENGTH < length){
 +
198    return 1;
 +
199  }
 +
  .
 +
  .
 +
  .
 +
</pre>
 +
 +
 +
 +
According to the oscilloscope the I2C communications are running at about 192kHz, a little fast.  Here is documentation at the Arduino site about setting the I2C clock rate:
 +
 +
*  https://www.arduino.cc/en/Reference/WireSetClock  . . . Wire.setClock() class method not found on localhost!
 +
 +
Another place where SCL frequency may be set . . .
 +
 +
<pre>
 +
user@localhost:/usr/share/arduino/libraries/Wire$ grep -nr lock ./*
 +
./Wire.cpp:84:  // perform blocking read into buffer
 +
./Wire.cpp:139:  // transmit buffer (blocking)
 +
./utility/twi.c:85:  SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
 +
./utility/twi.c:467:      // sends ack and stops interface for clock stretching
 +
</pre>
 +
 +
 +
2022-06-13
 +
 +
OpenMV IDE and Arduino Nano:
 +
<ul>
 +
*  https://blog.arduino.cc/2021/08/24/power-of-python-for-arduino-nano-rp2040-connect-and-nano-33-ble/
 +
</ul>
 +
 +
 +
<!-- comment -->
  
 +
== References ==
  
FreeRTOS port to Arduino . . .
+
<!-- comment -->
  
*  ust wanted to offer this in case you wrote back and the message bounced
 
  
  
  
 +
<!-- comment -->
 
<!-- comment -->
 
<!-- comment -->

Latest revision as of 20:08, 13 June 2022



Getting started:


The ATMEGA328P processor used in Arduino Uno boards:


Specific Arduino projects:


FreeRTOS port to Arduino:


Arduino Wire Library

2018-05-21 - Monday, looking at /usr/share/arduino/libraries/Wire/utility/twi.c, routine twi_writeTo() error codes:

177 /*
178  * Function twi_writeTo
179  * Desc     attempts to become twi bus master and write a
180  *          series of bytes to a device on the bus
181  * Input    address: 7bit i2c device address
182  *          data: pointer to byte array
183  *          length: number of bytes in array
184  *          wait: boolean indicating to wait for write or not
185  *          sendStop: boolean indicating whether or not to send a stop at the end
186  * Output   0 .. success
187  *          1 .. length to long for buffer
188  *          2 .. address send, NACK received
189  *          3 .. data send, NACK received
190  *          4 .. other twi error (lost bus arbitration, bus error, ..)
191  */
192 uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop)
193 {
194   uint8_t i;
195 
196   // ensure data will fit into buffer
197   if(TWI_BUFFER_LENGTH < length){
198     return 1;
199   }
   .
   .
   .


According to the oscilloscope the I2C communications are running at about 192kHz, a little fast. Here is documentation at the Arduino site about setting the I2C clock rate:

Another place where SCL frequency may be set . . .

user@localhost:/usr/share/arduino/libraries/Wire$ grep -nr lock ./*
./Wire.cpp:84:  // perform blocking read into buffer
./Wire.cpp:139:  // transmit buffer (blocking)
./utility/twi.c:85:  SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
./utility/twi.c:467:      // sends ack and stops interface for clock stretching


2022-06-13

OpenMV IDE and Arduino Nano:


References