Hello, I need your help 

I have to read data from an SPI master device, which sends the clock at 10 
MHz. Since the SPI kernel driver only allows to the beagle bone to working 
as SPI Master I had to implement this functionality using a PRU.

>From what I've read throughout the internet the PRU processing rate is 200 
MHz, so I thought I could easily read data at 10 MHz. Oddly, it happens 
that with transmission rates up to 2.5 MHz I am being unable to catch all 
the rising edges on the clock pin.

So, here's what I did:

In the PRU0 I wrote the following code:

bool WaitForRisingEdge_sclk(uint32_t sclk)
{ 
state[0] = ((__R31&sclk) == sclk) ?  true :  false;
if((state[0] == true) && (previous_state[0] == false))
{
previous_state[0] = state[0];
return true; //Rising edge 
}
else{
previous_state[0] = state[0];
return false;
}
}

void main(void)
{ 
while(1)
{
START:
count_clocks = 0;
while(gpio2[GPIO_DATAIN/4] & P8_8) //Receive notification from the beagle 
bone to read data
{ 

LOOP:
if(WaitForRisingEdge_sclk(sclk)) // wait for rising edge on clock pin
{
//buffer[i] = ((__R31&miso) == miso)?  buffer[i] | 0x01 << k : buffer[i] | 
0x00 << k; 
//buffer[i] =   buffer[i] | 0x01 << k; 
count_clocks++; 
}
else if(WaitForRisingEdge_cs(cs))
{
gpio2[GPIO_SETDATAOUT/4] = P8_7; // Notify the beagle bone that the data 
was already read
buffer[2600] = count_clocks;
goto START;
}
else
{
goto LOOP;
} 
} 
}
}


and I did one simple program ON PRU1 which sends at a certain frequency. I 
got to the conclusion that with transmission rates up to 2.5 MHz and can't 
count all the clocks. I was wondering if there is any better way for 
reading the rising edge, I might be lossoing performance on that function 
itself.

Thank you very much for your help,
-- Fred Gomes



-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/0beef84d-177e-4d3a-b877-42728c5891f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to