GNU C sample code for serial flash

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi all,
Im kinda new to this, and require some quick info to speed up development for my thesis. hope you can help.

I am designing an in vehicle data logger to store sensor info in a car. This will use the AT90S8535, as well as a few ST M25P80 IC's to store the data to.

I understand the operation of these chips but would like tutorials/sample code to see how data is written to and retrieved from memory. The data will generally be integers, but I may be adding ascii values of commas (,) to seperate the values for later viewing in MS Excel.

Any feedback would be of help.
Thanx.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Steven,

I use the M25P40 in combination with the ATMEGA162. See attached file for my source code.
Some remarks :
* The code could also be used for M25P80 - but I never tested it. The advantage of the M25P40 : it is also available in SO-8 enclosure, which is usable in prototypes
* I must cleanup this code, but my program is still under development. It could be that there is also some extra code in between for reading my ADC
* What voltage do you use ? My '162 runs on 5V, the memory on 3v3. Works great with just a 3v3 regulator and an 1k pull-up on the Data Out of the memory c
chip

Question :
What do you mean by 'adding ascii values' ? When transporting your data from memory to excel, your processor will take care of this (I assume). You processor can than translate the integer from memory to ascii. Saves huge amount of memory and searching for data in the memory is much easier

Greetings,

Patrick

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Patrick,

Thanx for the code.

By adding ascii values (ie integer value of a ',' ) i meant that i cant directly write a comma to the IC (or can I???) But yes I know what you mean about it taking up memory.

I will be using similar voltages for my micro and IC. Are there any strange things to look out for when hooking up the micro to the memory IC? Are there any differences to what is mentioned on the data sheet, and if so, is it possible to obtain a copy of your circuit dia?

Finally, does the ATMEGA162 have onboard ADC. I will be utilizing the onboard adc and was wondering if the code you supplied was using an onboard adc, or external...

Thanx again. It is always easier when i have code to relate back to the data sheets. Im a software guy....

regards,
steven.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My connections are :

ATMEGA162.PC1 to M25P40./S
ATMEGA162.MISO via 1k to M25P40.Q
3V3 to M25P40./W
0V to M25P40.4
ATMEGA162.MOSI via 1k to M25P40.D with a pullup (10k) to 5V
ATMEGA162.SCK via 1k to M25P40.C
3V3 to M25P40./HOLD
3V3 to M25P40.VCC

The 1k resistors are because of the ISP interface for programming the processor
I connected the MP25P40.D to the ATMEGA directly, this is not exactly written in the datasheets but I found no problems with it.

The '162 does not have an on-board ADC, but there are analog comparator inputs and PWM outputs so you could make an ADC with those. I never did this with AVR so you have to check how precize it will be.

Patrick

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanx Patrick,

I appreciate the help....

Rgds,
Steven.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Patrick,

 

do you have stil this sample of source for SPI flash?

Need for get alive my m25p80

 

regards

Daniel

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Daniel,

 

You have resurrected an eleven-year-old thread.  And I would hazard a guess that Patrick hasn't been around here in a while.  Note how his userid is 'admin'.  Posts that were made by accounts which no longer exist are assigned to that account.  The give-away clue is that the post was made in 2003, buy by a user who 'joined' in 2013.

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Thu. Nov 6, 2014 - 01:46 PM