AVR32 SPI clock frequency bug?

classic Classic list List threaded Threaded
2 messages Options
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

AVR32 SPI clock frequency bug?

I think I've spotted a bug in the calculation of the SPI clock
frequency on AVR32:

diff --git a/src/platform/avr32/platform.c b/src/platform/avr32/platform.c
index 75a2d65..899a19a 100644
--- a/src/platform/avr32/platform.c
+++ b/src/platform/avr32/platform.c
@@ -213,10 +213,10 @@ int platform_init()
   spiopt.modfdis = TRUE;
   spiopt.pcs_decode = FALSE;
   spiopt.delay = 0;
-  spi_initMaster(&AVR32_SPI0, &spiopt, REQ_CPU_FREQ);
+  spi_initMaster(&AVR32_SPI0, &spiopt, REQ_PBA_FREQ);

 #if NUM_SPI > 4
-  spi_initMaster(&AVR32_SPI1, &spiopt, REQ_CPU_FREQ);
+  spi_initMaster(&AVR32_SPI1, &spiopt, REQ_PBA_FREQ);
 #endif

 #endif

where
int spi_initMaster(volatile avr32_spi_t *spi, const
spi_master_options_t *opt, U32 pba_hz)
{
   ...

which I expect would really set a frequency of one quarter of that
which was asked for (and reported) since CPU=60000000 and PBA=15000000

but I don't have any SPI hardware to test this, so before I make this
fairly obvious change, which affects all AVR32 boards, has anyone
tried SPI on any of these boards? It seems a fairly obvious error but
I wouldn't want to break something that was working... if it was
working...

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: AVR32 SPI clock frequency bug?

Hi,

On Fri, Oct 14, 2011 at 2:14 PM, Martin Guy <[hidden email]> wrote:
> I think I've spotted a bug in the calculation of the SPI clock
> frequency on AVR32:
>
> diff --git a/src/platform/avr32/platform.c b/src/platform/avr32/platform.c
> index 75a2d65..899a19a 100644
> --- a/src/platform/avr32/platform.c
> +++ b/src/platform/avr32/platform.c
> @@ -213,10 +213,10 @@ int platform_init()
>   spiopt.modfdis = TRUE;
>   spiopt.pcs_decode = FALSE;
>   spiopt.delay = 0;
> -  spi_initMaster(&AVR32_SPI0, &spiopt, REQ_CPU_FREQ);
> +  spi_initMaster(&AVR32_SPI0, &spiopt, REQ_PBA_FREQ);
>
>  #if NUM_SPI > 4
> -  spi_initMaster(&AVR32_SPI1, &spiopt, REQ_CPU_FREQ);
> +  spi_initMaster(&AVR32_SPI1, &spiopt, REQ_PBA_FREQ);
>  #endif
>
>  #endif
>
> where
> int spi_initMaster(volatile avr32_spi_t *spi, const
> spi_master_options_t *opt, U32 pba_hz)
> {
>   ...
>
> which I expect would really set a frequency of one quarter of that
> which was asked for (and reported) since CPU=60000000 and PBA=15000000
>
> but I don't have any SPI hardware to test this, so before I make this
> fairly obvious change, which affects all AVR32 boards, has anyone
> tried SPI on any of these boards? It seems a fairly obvious error but
> I wouldn't want to break something that was working... if it was
> working...

I didn't try SPI on AVR32, but your fix is obviously right because of the AVR32 system architecture (as described in the datasheet) and because of this line from spi.c:

int spi_initMaster(volatile avr32_spi_t *spi, const spi_master_options_t *opt, U32 pba_hz)

I'd go ahead with it.

Best,
Bogdan

>
>    M
>


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev