Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

hi john

Status
Not open for further replies.

hani_a

New Member
first of all, thanks a million for your time; i've programmed several analog devices and they all worked fine, but when it came to memory.. i got really stuck. now here is what i'm doing exactly, do you see anything wrong?

1) i went to **broken link removed** and tried to use their code. of course, i made the necessary modifications to allow their code to work with mine (constants, bits sent, ..etc).
2) i used spi mode 3 and put the following in main:

main(){
.....
PORTB=0x00;
DDRB=0xB0;

SPCR=0x5C; // spi mode 3, almost sure now... confirmed with audionotes
SPSR=0x00;

lcd_init(24);

DFlashInit();

WriteBufferDF(0x00 ,'c', BUFFER2);

delay_ms(1000);

ch = ReadBufferDF(i, BUFFER2);

/* then i'd put ch on the lcd and i've always received 0xff for ch .
could you see anything i'm doing wrong? i could attach all my code if you think it could help at all in diagnosing my problem.. again, thanks a million for your help!
*/



}
 
Do a good search on AVRFreaks.net. There have been a lot of discussions about DataFlash lately. Many are about using 3.3V dataflash with a 5V AVR. Also, if you have a scope, check out your data lines (MISO and MOSI) because if you're driving into any kind of resistance*, the rise times might be really skewed.

I don't use code from AppNotes in general, because by the time I figure it out I could have done it myself. If you want I can send you some code.

What uC are you using?

j.

*For example, if you have long leads, or added a resistor on the MISO line, like I did.
 
ok, thanks for your fast response...

the only reason i tried using the code on avrfreaks is because i haven't really got the hang of programming devices yet.. i'm new in the field :) .. as for the 3.5, 5 V problem.. i dont think it's a problem in my case. i'm actually using atmega16. if you have any code that might help me please forward it to me whenever you can, i'm so desperate for any help...

thanks again john!
 
For one thing, my SPCR = 0b01010000 = 0x50 (yours is 0x5C). Are you able to read the status register? Focus on that, first, and you should be doing well. I'm looking through some of my code and most of it is a wreck. I only have one program that writes to Flash, and it is designed to work with many devices and configurations, so it's really a mess. Which DataFlash, exactly, are you using? I may be able to write up a small demo program by stripping out excess code.

*Make sure that in your testing you're not repeatedly writing to the Flash. You can wear it out quickly.*

j.
 
i'm actually using software called codevision, which specifies for me SPCR. Secondly, what do you mean by wears off? the application i'm planning to use it for needs it to add/remove memory for at least 2 years!

actually, one other thing is that i dont have a scope at home, how useful do you find the scope? do you think i should get one?

hani a.
 
i'm actually using software called codevision, which specifies for me SPCR.

CodeVision will build an application based on basic parameters you set during the create project wizard. If you gave it incorrect information, that would mean the SPCR would be built incorrectly. All I can say is that my app works and it's SPCR is 0x50. Will another value work? I dunno.

Secondly, what do you mean by wears off? the application i'm planning to use it for needs it to add/remove memory for at least 2 years!

Flash wears out. It's called endurance. You can only write to an address a number of times, and then it won't work anymore. How many times is up for debate, since Atmel isn't saying. It's probably on the order of hundreds of thousands or millions, but it isn't infinate. So if you're writing a program that treats flash like RAM, or have some kind of loop that repeatedly writes to an address (a typical mistake would be to have an error checking scheme during writes that doesn't time out after a certain number of tries), you can wear out the Flash pretty quick.

how useful do you find the scope

Indespensible. Some people work without them. I don't know how. I got several off of E-Bay.

Try to read that status register. Don't even try writing until you can do that. The rest is easy.

j.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top