Go Down

Topic: Sketch works on Arduino 328P 5v, 16 MHz, doesn't work on 328p 3.3v, 8 MHz (Read 365 times) previous topic - next topic

vander

Hello.

I worked on a sketch for a vc0706 ttl camera for more than a year and it worked without problems. It was running on a barebones atmega 328p, 3.3v, 8 MHz (bootloaded with Nick Gammon's bootloading sketch). After it was ready I put it aside for more than a year and now I need it for a trailcam.

I picked up an 8 Mhz chip, loaded my sketch, took a picture (stored it on an SD card), took the card and tried to read the JPEG file but it was corrupted. Tried it again but still got a corrupted file. I tried a bunch of stuff but nothing worked (bootloaded a new chip, got rid of a bunch of power saving measures, setup a new breadboard project with the same wiring and the same devices). It only produced corrupted files.

Then, in desperation, I wired the breadboard for 16 MHz, 5v and used an uno bootloaded chip and it worked. Then, I bootloaded one of the 8MHz, 3.3v chips to work with 16 MHz, 5v and loaded the same sketch: It worked again.

Does anyone know why this could happen? I remind you that this project (sketch and board) worked a year ago!


Coding Badly


You are selecting a board with the wrong processor clock speed when you build.


vander



Coding Badly

How so?
In the Arduino IDE...

• Click the Tools menu

• Click Board

• Select the appropriate board


vander

Why is that the wrong clock speed? I'm running the chip on it's internal clock with two 0.1 uf capacitors. The board is Gammon's design for a barebones Arduino. The chip was bootloaded accordingly. I don't understand what you mean by 'wrong clock speed'.

vander

In the Arduino IDE...

• Click the Tools menu

• Click Board

• Select the appropriate board


The appropriate board isn't ' Arduino Pro or Pro Mini (3,3V, 8 mhz) w / ATMega 328'? Then what is the appropriate board?

Coding Badly

The appropriate board isn't ' Arduino Pro or Pro Mini (3,3V, 8 mhz) w / ATMega 328'?
That should be a reasonable choice.


vander

That should be a reasonable choice.


Well, it doesn't work. The other option I tested was lillypad with Atmega 328P. "burning" the sketch with either of these boards selected works, the project functions like it should (blinking the right indicator leds, creating the JPEG file in the SD card with the usual size - 45 Kb), but the JPEG file is always corrupted when I try to read it on a computer. The same setup, same sketch but with a chip with an UNO bootloader, a 16 MHz crystal and two 22PF capacitors works just fine and the file created is readable.

Can anyone tell me why that is? What am I missing?



DrAzzy

My guess is it's a power supply issue, if it works with the 5v 16mhz but not the 3.3v 8mhz, provided you're compiling for the right speed and all.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Coding Badly

Can anyone tell me why that is? What am I missing?
I suspect you can answer the question for yourself if you add error checking to the code that fetches the image from the camera.


vander

Well, it doesn't work. The other option I tested was lillypad with Atmega 328P. "burning" the sketch with either of these boards selected works, the project functions like it should (blinking the right indicator leds, creating the JPEG file in the SD card with the usual size - 45 Kb), but the JPEG file is always corrupted when I try to read it on a computer. The same setup, same sketch but with a chip with an UNO bootloader, a 16 MHz crystal and two 22PF capacitors works just fine and the file created is readable.

Can anyone tell me why that is? What am I missing?
I really need help with this. I've been searching all over the web for similar cases but can't find an answer. I know the clock speed afects the number of cicles and transmition speed, but that can't be the case since I  had this working a year ago. has anybody ever put a VC0706 working with a 8 MHz atmega 328P?

DrAzzy

I really need help with this. I've been searching all over the web for similar cases but can't find an answer. I know the clock speed afects the number of cicles and transmition speed, but that can't be the case since I  had this working a year ago. has anybody ever put a VC0706 working with a 8 MHz atmega 328P?
You say it worked with a 5v 16mhz arduino.

And you say it doesn't work with a 3.3v 8mhz arduino (on breadboard).

Two things:

* You say you're using a breadboard arduino. There are many inaccurate guides which omit the necessary 0.1uf capacitors between Vcc and Gnd and AVcc and Gnd right next to the chip. Omitting these may cause unpredictable instability (including inconsistent behavior between individual chips with identical code on them - process variation can impact sensitivity here), so you should always include them. Debugging an arduino on breadboard that doesn't have these caps is wasting one's time. Generally, you need a 0.1uf ceramic cap between power and ground on any digital IC, unless the manufacturer recommends something else.

* You say it worked at 5v/16mhz, not at 3.3v/8mhz, but what if you bootload for 8mhz, but run it at 5v? Does it work? If that fixes it, it points to a power supply problem of some sort.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

vander

You say it worked with a 5v 16mhz arduino.

And you say it doesn't work with a 3.3v 8mhz arduino (on breadboard).

Two things:

* You say you're using a breadboard arduino. There are many inaccurate guides which omit the necessary 0.1uf capacitors between Vcc and Gnd and AVcc and Gnd right next to the chip. Omitting these may cause unpredictable instability (including inconsistent behavior between individual chips with identical code on them - process variation can impact sensitivity here), so you should always include them. Debugging an arduino on breadboard that doesn't have these caps is wasting one's time. Generally, you need a 0.1uf ceramic cap between power and ground on any digital IC, unless the manufacturer recommends something else.

* You say it worked at 5v/16mhz, not at 3.3v/8mhz, but what if you bootload for 8mhz, but run it at 5v? Does it work? If that fixes it, it points to a power supply problem of some sort.
The first thing is contemplated on my project and on the breadboard. The second one, I'm going to give it a try when I get home.

Thanks a lot! I'll get back to you.

be80be

I had about this same thing happen I made a stand along uno and it works great I put it up and about a year later I see it and I think what the heck let's add it's own usb to serial and I did the dang thing pops up it can't be programmed.
Now what the heck It worked and all I did was nothing but a hook up a usb to serial.

Well after about 4 hours looking at this thing I found the problem I put a crystal on it and like I said it worked well the leg is broke on the crystal it now works when you press down on the crystal.

I fixed that it now works all the time but somethings are hard to find.

Bread boards pins can also get bad over time most time you remake it and it will work agin as it did before. 

Go Up