Arduino Nano: is SPI supported? - arduino

Can SPI hardware on the Arduino Nano be used?
On the Nano page it says:
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI
communication, which, although provided by the underlying hardware, is
not currently included in the Arduino language.
Yet there is an SPI library.
Please can someone explain this contradiction? I think, either
The nano page is out of date
SPI library is unsupported for the Nano SPI hardware but is supported on other boards
SPI library is implemented for the Nano in software only
Which is it?
Thanks

The correct answer is "some combination of the above":
Arduino Nano is based on the ATmega168/328 chip, which does support SPI in hardware.
The SPI library only supports hardware SPI (regardless of the Arduino model). Note that you could bitbang (relatively) slow SPI without any problems, this would be a relatively easy software implementation.
The status of SPI library should be considered same as the status of the Wire library: not part of core Arduino services (in contrast to PWM, ADC, and digital GPIO), but widely supported nonetheless.
So perhaps the closest answer in your multiple-choice question is "out of date". The status of SPI should look the same as the status of I2C.

This should be a comment but I haven't the rep.
As angelatlarge said, the SPI library is as supported for the Nano as it is for any of the other Arduinos. Except:
The Nano (like all Arduinos) has an LED attached to digital pin 13. Since, for the Nano, pin 13 is also SCLK for SPI, you may well run into trouble with high baud rates. If this is a problem for you, try removing the LED.
From the Nano's page: Source
...
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

The Nano's product page is out of date, but it has the same hardware and software SPI support as the other ATmega168/ATmega328p-based Arduinos.
Some archaeology in the wayback machine reveals that the functionally comparable Duemilanove's product page was changed from a hardware-but-not-software mention to a mention of SPI library support between September 15th and 26th of 2010. When the Uno came out, its product page was based on the then-current state of the Duemilanvoe's, so it has always claimed support.
A corresponding update should have been made to the Nano page, but this appears to have been overlooked.

Related

Atmel ICE C initial connection problems

I have ATMEL ICE C initial connection problems - it cannot read device signature, because of the target board voltage isn't between range of 1.8 to 5.5V. It has measured by the Atmel Studio as 1.3V (when target board is powered by the USB connector) or 0.3V (when USB disconnected from target).
It'a a brand new device, and i never used it before, may be i did something wrong?
I had used before AVR ISP handmade by myself, and had used previously programmed target board for this experiment, to avoid possibility, that board is dead. The target is works and blinking heart beat.
What i has done -
1.Connect the target board to the ICE programmer.
2.power target board by USB.
3.power programmer by USB from PC USB port.
4.open "device programming" tab in AS 7.
5.Make all settings for my chip atmega328p
6.press "apply" then 'read'
7.get err msg that voltage is too low.
(while i had measured it directly, by the digital voltmeter on pins +5V and GND on target
board, it's about 4.5V, same as in ISP connector - measured on 2 and
6 pins.)
=======================================================
#markus-nm where did you take your measurements?
i had measured on pin 2 and 6 of ISP connector and between pin +5V and GND on Arduino Nano board.
What reference was used?
i had used GND pin on target board for the reference.
Did you use the same USB Host for ISP and power?
no, power to target board was from the wall socket USB charger, AND power to Atmel ICE is from personal computer.
If not, did you connect the grounds?
no, but i guess that grounds are already connected on the target board.
Some links to your chip, your board and ISP would be helpful.
ATMEL-ICE-C https://www.microchip.com/en-us/development-tool/ATATMEL-ICE
ARDUINO NANO PRO https://store.arduino.cc/products/arduino-nano
If it's a custom PCB, provide some schematics. Show a wiring diagram of what you did.
no, i had used the standard Nano board (may be not original, but clone, but it is definitely working now, because it can be programmed by the AVRDUDE program and work.)
The Atmel-ICE, by design, has a lot of different ways to hook up the programming connector. Often when I see problems like this it's because the wrong connector is used. Keep in mind the programmer itself has both an AVR and a SAM port. For the Arduino Nano Pro, make sure it's plugged into the AVR port. After that, ensure you're using the correct programming connector on the adapter board that comes with the Atmel-ICE and that it's oriented correctly on the Nano's header.
If that all fails then something is broken.

I2C pins of nRF52832 Sparkfun breakout board require pull-up resistors?

I am trying to use press buttons via I2C using nRF52832 Sparkfun breakout board. I followed the steps given in nrf52832-breakout-board-hookup-guide and changed the I2C Data and CLK pins to 24 and 25, respectively. I connected these pins and GND of the board to the corresponding pins and scanned for I2C devices. But it gave error = 2 (no I2C device) for all addresses. Should I use pull-up resistors? I would appreciate any help.
Yes pull-up resistors on both SCL and SDA MUST be provided for I2C communication. Please see the following links:-
Infocenter specification (See very end of section)
Devzone Question 1
DevZone Question 2
DevZone Question 3
I also recommend asking similar questions on Electrical Engineering or directly on the Nordic DevZone as there is higher chance of this being answered quicker.
I hope this helps
Thanks for your reply. I think it depends on the I2C device that we are using. This module has internal pull-up resistors, but it may not be enough for some devices. So, I disabled the internal pull-ups by replacing GPIO_PIN_CNF_PULL_Pullup with GPIO_PIN_CNF_PULL_Disabled for both SDA and SCL pins in the library and used external ones.

PWM/PPM Output misses some edges

I am using ESP8266 (NODEMCU 3.0 or something) to make a quadcopter. Ive connected ardu pro mini to RC receiver so I am reading PPM values from it. Pro mini sends data with tx to ESP8266. ESP reads it with software serial with 115200 baudrate. I am communicating with MPU9255 (Waveshire) via I2C either.
My problem is that I cant fully controll my brushless motors. When I was using arduino instead of ESP8266, servo library was the best and reliable. But ESP's servo library is different, since its not AVR, and problems occurs. First of the servo library didnt want to work on most frequencies. I mean default is 50Hz (20000uS) and in this state ESC of motors did armed but unfortunatelly when changes was fast and short (1250-> 1370 -> 1250) it did miss that change like nothing happnd... This makes my D value in PID controller useless...
Sometimes on 100Hz freq all was working fine, but sometimes not...
When Ive started to use analogWrite only 500Hz was working fine, rest of freq didnt want to arm ESCs.
PS. I am using 3.3V to 5V converter for PPM/PWM pins so I am sure that the signal is fine for ESCs.
PS2. I dont have any osciloscope unfortunately.
The ESP82266 present on your module is a RF transceiver integrated circuit that can handle WiFi communication, both configured as a slave to a microcontroller such as the ones present on various Arduino boards, or as a standalone chip by having it's on-board Tensilica L106 32-bit processor programmed via an external SPI flash memory. If used as a slave, the communication between, for example, an Arduino an the ESP82266 can be done using different protocols such as SPI / SDIO or I2C / UART interfaces. Googling a comprehensive Tensilica L106 user guide on the internet doesn't seem an easy task, and it looks as if some people have already failed to find it. If you're seeking to add Wi-Fi capabilities to your quadcopter the solution I suggest is having the Arduino take control over the servos, motors, etc. and hand off messages via SPI to your ESP82266 module. If this isn't the answer you are looking for, please try to be clearer about it, maybe find someone to do as an English translator for you.
However, if this is what you're concerned about, and you would like to use the ESP82266 module as as standalone solution, please link its built-in processor datasheet and the relevant parts of the quadcopters code that might need debugging.

Configuring ATtiny85 to use external 8MHz oscillator?

I am using an ATtiny85 8 pin AVR to send AT commands to an RN42 Bluetooth module. I am programming the AVR using an Arduino as an ISP therefore writing the code in the Arduino IDE, using the SoftwareSerial library as the AVR has no UART port.
To ensure accurate clocking out of the data I have added an 8MHz oscillator (LFSPXO018045) on pin 2 but I'm not sure how to make sure the AVR is using this and not just defaulting to the internal osc. I've seen mention of "Fuses" that need setting? Is there any in-code things I need to do like set a register flag or any pre-scalers?
Here is the Eagle circuit and option I found so far but don't know if there's anything else that needs doing too?: PCB & IDE
By the way this is my first question so please be lenient if I've missed something!
Clock settings of AVR MCUs can be changed via using the dedicated Fuse bits. These Fuse bits unfortunately cannot be modified from software. The only way to program the Fuse bits is either using a JTAG programmer or an ISP programmer (like: USBasp, AVRISP mkII or you can use an Arduino as an ISP programmer with the right sketch on it).
This AVR Fuse calculator tool can be used to determine what settings and Fuse values you need to program.

Program a pic32mx250f128b with pic32prog on an arduino uno

I'm currently trying to burn the pinguino bootloader in a pic32mx250f128b which is 5V tolerant with an arduino uno. I'd want to try pic32 chips, but I haven't a pickit3 now, I can only access to pickit2.
So to burn the bootloader I'm using an arduino uno, and use the bitbang sketch from pic32prog to try to burn it.
For the wiring I did this :
All VDD and the VUSB3V3BUS pins are wired to the 3V3 regulator of the arduino uno.
All VSS pins are connected to the ground of the arduino uno.
Arduino D2 (PGC) is directly connected to PGEC1
Arduino D3 (PGD) is directly connected to PGED1
Arduino D4 (MCLR) is directly connected to MCLR
But actually, when I launch pic32prog I always have this output :
Programmer for Microchip PIC32 microcontrollers, Version 2.0.218
Copyright: (C) 2011-2015 Serge Vakulenko
(ascii ICSP coded by Robert Rozee)
Adapter: ... OK1 OK2 - ascii ICSP v1E
No target found.
I tried also with the couples PGEC2/PGED2 and PGEC3/PGED3.
I haven't tried to use a crystal yet, but I think from what I read it's not needed for ICSP programming.
For now here is what I've done on my breadboard :
photo of the pic on the breadboard
I don't know what could cause this detection problem,
Thank you very much for your help :)
Edit : I tried several things and here is where I am :
I added the pull-up on MCLR, capacitors on VDD pins, and others recommended : Still the error No target found.
I saw that pic32prog add compatibility with pickit2 so I tried it : this time the pic is detected but I get this error : Unknown CPUID : ffffffff. I tried also with a new pic32mx250 on the pickit2 to be sure it wasn't the first which was damaged.
Finally to recheck my connections I found another version of the datasheet. In this one it seems that PGECx and PGEDx pins aren't 5V compatible... -> So I'll test with 3.3v compatible circuit this time
you need 3k3 pullups to the 3v3 supply rail on both PGC and PGD. these two outputs are 'open collector' (simulated) and the 3k3 resistors define the logic '1' voltage fed to the PGC and PGD pins of the target PIC32.
as mentioned by others, you also need a 10k pullup on MCLR. in addition, you need to ensure that all Vcc pins (13 and 28) are connected together, all ground pins (8, 19 and 27) are connected together, and that there is a 10uF low ESR ceramic capacitor from pin 20 to ground (a 22uF tantalum will do).
see the "ascii ICSP construction guide" article here:
http://www.thebackshed.com/docregister/Browse.asp
the article includes a schematic of what is required.
cheers,
rob :-)
the 10uF low ESR ceramic capacitor on pin 20 is crucial. pin 20 connects ONLY to this capacitor, nothing else. without it, the core of the PIC32 will not run and programming will be impossible.
the reason for this is that the core of the PIC32 runs at 1.8 volts, and the capacitor on pin 20 is part of the circuitry that generates this supply. in your photo it looks like pin 20 is not connected to anything.
cheers,
rob :-)

Resources