SPIF problem

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

Hello everyone,

I have a problem and i need your help,

 

I am currently trying to build a software component for SPI interface in atmega1284p,

however when i try to send a byte of data when a button is pressed, i receive a lot of sent bytes within the same click of the button see below

 

        while(uDIO_GetPin_Value(A, DIO_PIN0) == 0)
        {
            hwSPI_writebyte(0x10);
        }

 

and when i use an interrupt driven SPI, the ISR is triggered after the first byte, and only byte is transferred,

However when i try to push the button another time, nothing happens,

 

Note : I am using Proteus for reading the signal on the oscilloscope

 

Thanks in advance,

atarek

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

How long is the button pressed and how long does it take to send a spi byte? In answering these questions you should find the answer to your problem.

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

Why while? Surely you wait for one button transition (and I hope you understand debounce?) and then you do ONE transfer. while() means "keep doing this" so it's little surprise if something is then done multiple times.

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

I am using Proteus to simulate the physical layer, so it is just a click of a button

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

If i use If statement it still return the same result,

I am guessing it is related to SPIF interrupt flag, i think when using interrupt the code will still waiting for transmission to complete (SPIF == 0) and it never will,

 

Thank you

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

As you haven't shown us the code how can we possibly guess?