reading data from AT45DB041B(data flash) on STK600 using interrupt

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

Hi,

                I am trying to read the data from AT45DB041B(data flash) single byte at a time using interrupt on STK600. I have done the same by polling method and its working properly. But when I try it using interrupt its not working. My code files are in attachments.

                Can someone tell me solution to my problem.

               

              

             

 

Attachment(s): 

This topic has a solution.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Read this:

 

http://www.avrfreaks.net/forum/t...

 

Basically the flag set in the ISR that main() is waiting for must be "volatile".

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

Hi Clawson,

                    Okay I will go through your link only another question to ask is the sequence of cs_low() and cs_high() that I have repeated for every byte is correct or I have to write cs_low() at beginning and cs_high() at end at once.  

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

Hi,

         I declared that flag as flag as volatile but its not working yet. And when I checked using LED PORT I found that the condition if(dummy_byte_cnt>255) in ISR never gets true.

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

In pg_read() you deselect the CS, therefore that command will be cancelled, not paused. CS should stay asserted while the command is written and while any data is arriving from the dataflash.

I do not understand what your interrupt routine actually does. :confused:

There are several methods you can use to communicate with the dataflash.
I would send the commands using polled SPI because most commands are only 4 bytes in length.
Use a simple SPI interrupt handler to receive the data and store it somewhere and set a flag when all bytes have been received.
The main routine processes the received data (based on what the flash command was) when the 'all data received' flag is set by the ISR. (or if a timeout occurs).

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

Hi,

              I want to send only first byte of opcode by polling method and enable interrupt in the same function then send rest of bytes one at a time in ISR. Once all command bytes are sent I want to receive data in ISR one byte at a time after all data bytes are received set data receive flag and display the data on hyperterminal.

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

Hi Mikech,

                   I did the change as per your suggestion but its not working yet.

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

Problem Solved.

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

Mandar Joshi wrote:

Problem Solved.

 

So how about saying how the problem was solved... so that someone else in future does not have to go through your pain. Seems only fair don't you think?

 

Ross McKenzie ValuSoft Melbourne Australia

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

                      Trying to read data using interrupt but only single byte at a time. So sent opcode first by polling method then rest of bytes(page address,starting byte address and don't care bytes) through interrupt with  one byte at a time.

                      Most important toggle SS only once (low at beginning before opcode byte and high after data reception)After receiving first data byte just increment starting byte address and repeat whole cycle as above for next byte and so on. That is how it worked for me.