Standalone Atmega328p-pu not working without external crystal - arduino

Recently i bought some standalone Atmega328p-pu (just the MC not a arduino board). At the time i forgot to buy a 16mhz crystal but according to many sources on the internet i could run it without the crystal. but it never worked. I used a Arduino Nano as the programmer (with the Arduino as ISP sketch). made the following connections.
Nano ---> Atmega328p-pu
D13 Pin 19 (SCK)
D12 Pin 18 (MISO)
D11 Pin 17 (MOSI)
D10 Pin 1 (RESET) (tried it with and without a pullup resistor to 5V).
5V VCC
with those connections when i try to burn the bootloader or upload sketch using programmer, my upload fails. i get Device signature 0x000000. i have tested this on other MCs as well and none of them worked. few days later i bought a 16mhz crystal and connected it as given bellow. (keeping previous connections as they were).
Crystal Pin 1 ---> Pin 9 (XTAL 1)
Crystal Pin 2 ---> Pin 10 (XTAL 2)
22nF capacitor between the pins and ground
Only after this did the my MC work. i could burn the bootloader and upload code to the Atmega328p-pu using my Nano as the programmer
So. the question is why was the Atmega328p-pu not working without the crystal? i have seen videos on youtube where a crystal was not used and the MC worked fine.
Note: when i say MCs i mean other Atmega328p-pu's

Without external clock, you can just have 8MHz. With a crystal, you arrive to 16MHz.
If you use the one from an Arduino board, it is already programmed and it will not work without a crystal (you can put any crystal to upload your sketch, from 100kHz to 12MHz).
But it is important that you never upload a sketch with external crystal fuse flag set. Because at this point, you need to connect a crystal to pins 9 to 10 (also by hand) to be able to start/program it again.
Arduino IDE has the default Arduino boards. If you have your own AtMega328, you should install this board:
https://github.com/MCUdude/MiniCore
Then you can just set your 328 with the custom crystal settings:
If you set the interal crystal (limited to 8MHz), you can use pin 9 and 10 for other purposes.

Related

Error in Arduino with Espressif ESP32-CAM [duplicate]

I've just recieved my very first esp32cam (AI THINKER) today and I was excited to test it, but I'm unable to upload any code to it. I'm always getting the following error:
Failed to connect to ESP32: Timed out waiting for packet header
So, the FTDI I'm using is the FT232r with the following wiring scheme
FTDI Wiring
How I reproduce this error:
Plug everything
Order IDE to upload the sketch
Wait for the "connecting" text
Press the RST button
Also:
Plug everything
Press the RST button
Order IDE to upload the sketch
I've already tried:
Switching to 3.3v (plugged on 3.3v pin)
Using external 5v power supply (plugged on 5v pin)
Using another computer
Swapping RX TX
Trying in different upload speeds
Holding RST button
Switching board between ESP32 Wrover Module and AI Thinker ESP32
I'm I doing something wrong or there's just something faulty?
I have delved for a solution in this regard for weeks and it seems I have a solution.
Findings-
FTDI module is probably faulty or not supported for each instance.
Aithinker Board is not compatible with esspressif (use ESP32Wrover, more details below )
I have an esp32cam from Esspressif, not Aithinker.
I was trying with FT232rl , No matter what Voltage/jumpers/USB cable I used, it didn't work. Always stuck with fatal timed out error.
After many futile attempts with FTDI breakout, I gave my Arduino UNO a try (please note my UNO has mega16u2 chip as USB serial chip (top right corner just beside the oscillator) and fortunately it worked.
I have read that CP2102 is also working.
**Here are the steps to follow-**
Arduino ESP32Cam connections
3.3 Arduino --------- 3v Esp32CAM
GND Arduino ------------ GND Esp32CAM
RESET Arduino to Ardunio GND
RX Arduino -------------- VOR Esp32CAM (this is not a mistake RX to rx & TX to tx)
TX Arduino -------------- VOT Esp32CAM
GPIO 0(zero)(written as IO0) Esp32CAM to GND Esp32CAM
I didn't have any need to press the reset button in any part of the operation before & during uploading.
I am assuming You have pre-installed the esp32 board manager.
Now select the correct COM port where your Uno (in this case) is
plugged in.
Select the correct board as mentioned
Tools>Board>ESP32 Arduino > select ESP32 Wrover Module
Some uploading setups are to be Done (Under Tools, these will only appear when the Wrover module is selected )
Upload speed -- 115200
Flash Frequency -- 40Mhz
Flash Mode -- QIO
Partition Scheme --- Huge App
Port ---- select the right com port for your breakout or UNO
JUST press upload and relax
After a while, you will be able to see this message
Leaving...
Hard resetting via RTS pin...
Disconnect the Esp32Cam GPIO 0 and GND
Power the ESP32Cam with 5/3v with external power supply (Arduino or other breakouts may not be able unless you are connected with a Powered USB Hub)
keep TX, RX, & GND of the 2 boards connected, don't disconnect Arduino Reset and GND.
Press Reset on ESPCAM and open Serial monitor and you will be able to see the IP address of the cam if it was configured with your wifi correctly.OR get any network scanner App on android or windows.
I hope it helped.
Pre-requisites for flashing:
ArduinoIDE 1.8.12
Core ESP32 1.04 (at time of writing)
Select board AI Thinker Cam
uplooad speed 921600
freq 240Mhz
flashfreq 80Mhz
mode QIO if not working try DIO
partition scheme default
Serial monitor is closed
NO hardware connected to the pins of the ESPcam
Make sure the USB cable is a data cable and NO loading cable only
check Windows device manager if programmer is shown and has max speed / 8n1 hardware
Connections
FTDI - ESP32
GND GND
5V 5V
TXD UOR
RXD UOT
If you use an AIThinker Cam clone you have to ground GIPO 0:
connect GPIO 0 with a dupont wire connected to GND
press reset
compile and upload (use AI THINKER CAM)
optional:
press reset
upload filesystem data (SPIFFS)
disconnect GPIO 0 and GND
press reset
code should execute
And yes you have to do it every upload, on my dev board I soldered a little switch with proper isolationSome more solutions from experience:
If there is still a problem use a 10K (or so) pull-down resistor between RX0 and GND (test on breadboard before soldering)
Pressing and holding (!) the boot-button while uploading on some "bad" boards
Happened with a "normal" ESP32 board to me - just to be sure - I got an ESP8266 in an ESP32 packaging. Configuring for the ESP8266 solved the issue of uploading.
In my case I forgot to remove the SD card. Other users recommended removing unnecessary connections to the pins-- and the SD card technically uses some of those :)
This was solved by using other jumpers. It seems one of the jumpers used in the wiring was faulty.
If you're having the same issue and tried everything in this post, try checking your cables!
Another solution here. Just to add, I tried everything on this QA, as well as many other things suggested online. e.g. tested by powering from 3.3V then 5V, various permutations of holding the reset button down and disconnecting IO00 from GND at the point of flashing. Changing various settings in Arduino IDE/
I was unable to flash a single one of the 5 ESP32-CAM boards I bought. Spent a good two hours on it. I even continuity tested every pin on the board to its ESP32 chip pad, and all the hookup wires were tested too. The board seemed fine.
Then I soldered a 100uF capacitor between 5V and GND, and used my USB-UART 5V power... tested and worked straight away. No need to pull out the IO00->GND connection and no need to press RST button on the board during flashing. (Of course, pull out IO00->GND after flashing complete.
So - it was a power problem.
I can only guess that the cheapo regulator they used on the copy of board that I got was not quite efficient enough, but basically that capacitor resolved the issue.
p.s. the ESP on board was marked "ESP32-S". I selected "AI Thinker ESP32-CAM" in Arduino IDE as suggested by most people online, and this worked.
There are 3 pins marked GND on the ESP32-CAM board. Buuuuut (!) the one marked GND/R just by the U0T is NOT connected to other grounds or anywhere else I could had find. Check with a multimeter and use a REAL GND. It just worked for me after days of puzzling.
If you try it with arduino it works but its needed to press reset button on esp32 before you upload your code
Basically I was facing the exact same problem fro quite some time. What worked for me was that as the chip was flashing, shifting the power wire from 5V to 3V3 pin. I do not know why but it workes. When esptool starts flashing at 2%, switching the cable just then, despite having 5V from supply into the 3V3 point made the flashing successful. I do realize this is probably a bad answer to your problem since it involves oversupplying voltage to the chip on the wrong point as it is flashing and could damage the chip. However, if anyone is tired of debugging and are at the point where you are considering throwing the chip away, might as well try my method. For other's who value their chip, don't try this method and if you still do, kniw it is at your own risk. But it worked for me after 3 days of just messing around with connections.

How to read a flash drive with the MAX3421E USB Host module built in an Arduino Mega 2560?

I'm using an Arduino Mega 2560 (Iteaduino ADK v1.0d to be more specific, like the one shown below). It has a built-in MAX3421E USB Host module.
The main goal is: I want to read a text file from a flash drive plugged into its USB port.
From the board's documentation, I know that the USB Host module uses the following Arduino pins:
7 - RST
50 - MISO
51 - MOSI
52 - SCK
I have tried using Kroll's library (https://github.com/felis/USB_Host_Shield_2.0) to do some mass storage testing and see what happens (i.e. https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/USB_desc/USB_desc.ino), but nothing happened.
Also, I tried using the Greiman's library (https://github.com/greiman/UsbFat) with the DriveInfo example (https://github.com/greiman/UsbFat/blob/master/UsbFat/examples/UsbDriveInfo/UsbDriveInfo.ino) and it only returned:
UsbFat version: 20141220
FreeRam 7075
Error: initUSB failed
I think there might be the pins settings that are pointing to somewhere else, or I'm just using the wrong libraries for my board.
Does anybody know how to implement it to use the built-in USB port to read a flash drive?
The solution was to select Arduino Mega ADK as the board and the code uploads and runs.

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 :-)

Arduino Nano - Programmer not responding

I cannot seem to upload the simple blink program to my Arduino Nano. I keep getting the message:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
What I have tried already with a lot of suggestions on Google. I have tried it on both a Windows 7 & 8 machine and with 2 different Nano's:
Set my Board to Arduino Nano
Set my Processor to ATmega168
Set my port to COM1
On windows 8 turned off driver signature
Installed the FTDI Driver
Checked my drivers in control panel
USB controllers says USB Serial Converter
USB Serial port says USB Serial Port (COM1)
Rebooted a Lot!
When I plugin the nano to the USB it starts blinking the L led 180 times a minute. When I start uploading, L blinks at about 80-100 times a minute, blinks the rx and then start blinking the L led fast again.
As of 2018, if you have a genuine Nano (from Arduino), you could be getting this error because of an update to the bootloader on all Nanos shipped by Arduino after January 2018 (Read the note (highlighted in bold) here: https://www.arduino.cc/en/Guide/ArduinoNano#toc4). You will have to update your Arduino AVR Core to 1.6.21 in Boards Manager Under Tools -> Board in the ArduinoIDE to use your shiny new Nano.
Conversely, if you have an older Nano (older than Jan 2018), but recently updated your ArduinoIDE, you should make sure the Processor you selected is ATmega328P (Old Bootloader) under Tools -> Processor.
If your Nano is not genuine (i.e. a 3rd Party Nano), then you may have to manually install the bootloader required to work with it. (The 3rd party should have documentation about this)

Arduino, Firefly, Servo not communicating

I am trying to control 2 servos using firefly. I had it working (proof) and now it doesn't seem to work...
my setup is as follows:
- Arduino Mega 2560 R3
- Arduino sensor Shield V5.0
- 2 standard servos (plugged into pins 9 and 10 in the sensor shield)
- 7.5V wall power supply
- USB cable to computer
I'm running Rhino SR 8 on a 32 bit Windows Vista machine
I have Version 0.9.0014 of grasshopper (the latest) and Firefly_Build_1.0067 (also the latest)
I have flashed my Arduino board with the latest firefly firmata (updated September 10th, 2012)
I have checked that I am using the "MEGA write" box
I have got the right bits going to the right pins and I have checked that they all have "servo" ticked instead of "digital" or "pwm"
My servos and board work perfectly well with the normal Arduino software, but just not any longer with firefly.
The port shows correctly as COM 4 and opens fine in firefly.
When I move the slider to control the servos, the TX light is on and the RX light flashes, but no servos move...
(to confirm: everything works with the sweep example in arduino, so I have eliminated power and wiring issues)...
Any ideas what might be the problem?
I've tried re-installing, switching off and on many times, changing cables, trying a different board (also doesn't work any more with the duemilanove), trying all pins on the shield, trying one servo without the shield, trying one servo with the shield, lots of googling, lots of searching forums, unblocking the firefly installation files in explorer, lots of things... I'm all out of ideas... And very confused as it was working just a few days ago... Am I just missing something really obvious or could there be an issue with the software at my end?
You should try to connect a resistor and LED to the signal port of the servo's, that way you can see if the servo's actually receive the signal or not.

Resources