Sign in

username:

password:



Not a member?

Search lpc2000



Search tips

Subscribe to lpc2000



lpc2000 by Keywords

2106 | ADC | ARM7 | Atmel | Bootloader | CAN | CrossStudio | CrossWorks | DDS | ECos | Ethernet | ETM | FIFO | FLASH | FPGA | GCC | GDB | GNU | GNUARM | GPIO | I2C | IAP | IAR | JTAG | Kickstart | LCD | Linux | LPC | LPC-E2294 | LPC2000 | LPC2100 | LPC2104 | Lpc2106 | Lpc210x | LPC2114 | LPC2119 | LPC2124 | LPC2129 | Lpc2138 | LPC213x | LPC21xx | LPC2210 | LPC2212 | LPC2214 | LPC2292 | LPC2294 | LPC2xxx | LPC3128 | MCB2100 | Olimex | Philips | PWM | Rowley | RTC | RTOS | SPI | SSP | UART | UART0 | UART1 | ULINK | USB | Watchdog | Wiggler

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | LPC2000 | DMA & SSP big endian

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

DMA & SSP big endian - almagor100 - Oct 13 8:21:11 2009

Hi,
I'm using LPC2478.
My board connected to Analog Device ADE7878 chip that has Fast SPI that send continusly data.
Its 3 wire protocol that start the CS bit then clock out 7*32 bits (total 7*4 bytes=28 bytes) then raise the CS - wait 30Micro Second and start again.
The Clock is about 4mhz.
I want to fill a large area (in sdram) with the data.
I use the DMA with SSP and it works perfect.
I connect the CS line also to EINT0 so I know when the transfer is finished and then I reprogram the destinatin address for the DMA to fill the next block.
My problem is that the data is 32 bit - big endian (most first) and I need to swap the bytes to use them as a 32 bit integer.
Because I deal with a lot of data I don't want to waste time of this swap.
I read that the DMA has a bit for Big Endian mode. But when I set it on I don't get data at all (all 0).

I belive I have misunderstood of the SBSIZE DBSIZE SWidth & DWidth in the DMACC1Control register.

Any help?

Regards,
Doron

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )


Re: DMA & SSP big endian - profdc9 - Oct 13 8:31:48 2009

You probably should take a look at

http://graphics.stanford.edu/~seander/bithacks.html

Reverse bits in word by lookup table

static const unsigned char BitReverseTable256[256] =
{
# define R2(n) n, n + 2*64, n + 1*64, n + 3*64
# define R4(n) R2(n), R2(n + 2*16), R2(n + 1*16), R2(n + 3*16)
# define R6(n) R4(n), R4(n + 2*4 ), R4(n + 1*4 ), R4(n + 3*4 )
R6(0), R6(2), R6(1), R6(3)
};

unsigned int v; // reverse 32-bit value, 8 bits at time
unsigned int c; // c will get v reversed

// Option 1:
c = (BitReverseTable256[v & 0xff] << 24) |
(BitReverseTable256[(v >> 8) & 0xff] << 16) |
(BitReverseTable256[(v >> 16) & 0xff] << 8) |
(BitReverseTable256[(v >> 24) & 0xff]);

// Option 2:
unsigned char * p = (unsigned char *) &v;
unsigned char * q = (unsigned char *) &c;
q[3] = BitReverseTable256[p[0]];
q[2] = BitReverseTable256[p[1]];
q[1] = BitReverseTable256[p[2]];
q[0] = BitReverseTable256[p[3]];

Reverse an N-bit quantity in parallel in 5 * lg(N) operations:

unsigned int v; // 32-bit word to reverse bit order

// swap odd and even bits
v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1);
// swap consecutive pairs
v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2);
// swap nibbles ...
v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4);
// swap bytes
v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8);
// swap 2-byte long pairs
v = ( v >> 16 ) | ( v << 16);
For example.

Dan

See the Jumentum Network BASIC project
http://jumentum.sourceforge.net/

--- In l...@yahoogroups.com, "almagor100" wrote:
>
> Hi,
> I'm using LPC2478.
> My board connected to Analog Device ADE7878 chip that has Fast SPI that send continusly data.
> Its 3 wire protocol that start the CS bit then clock out 7*32 bits (total 7*4 bytes=28 bytes) then raise the CS - wait 30Micro Second and start again.
> The Clock is about 4mhz.
> I want to fill a large area (in sdram) with the data.
> I use the DMA with SSP and it works perfect.
> I connect the CS line also to EINT0 so I know when the transfer is finished and then I reprogram the destinatin address for the DMA to fill the next block.
> My problem is that the data is 32 bit - big endian (most first) and I need to swap the bytes to use them as a 32 bit integer.
> Because I deal with a lot of data I don't want to waste time of this swap.
> I read that the DMA has a bit for Big Endian mode. But when I set it on I don't get data at all (all 0).
>
> I belive I have misunderstood of the SBSIZE DBSIZE SWidth & DWidth in the DMACC1Control register.
>
> Any help?
>
> Regards,
> Doron
>

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

Re: DMA & SSP big endian - almagor100 - Oct 13 8:38:33 2009

Hi Dan,
But this is not my problem. I'm not asking how to swap a word. I don't have time to swap it. I want the DMA to handle the swaping as the data arrive...
The LPC2478's DMA has this option but I can start it...
Doron

--- In l...@yahoogroups.com, "profdc9" wrote:
>
> You probably should take a look at
>
> http://graphics.stanford.edu/~seander/bithacks.html
>
> Reverse bits in word by lookup table
>
> static const unsigned char BitReverseTable256[256] =
> {
> # define R2(n) n, n + 2*64, n + 1*64, n + 3*64
> # define R4(n) R2(n), R2(n + 2*16), R2(n + 1*16), R2(n + 3*16)
> # define R6(n) R4(n), R4(n + 2*4 ), R4(n + 1*4 ), R4(n + 3*4 )
> R6(0), R6(2), R6(1), R6(3)
> };
>
> unsigned int v; // reverse 32-bit value, 8 bits at time
> unsigned int c; // c will get v reversed
>
> // Option 1:
> c = (BitReverseTable256[v & 0xff] << 24) |
> (BitReverseTable256[(v >> 8) & 0xff] << 16) |
> (BitReverseTable256[(v >> 16) & 0xff] << 8) |
> (BitReverseTable256[(v >> 24) & 0xff]);
>
> // Option 2:
> unsigned char * p = (unsigned char *) &v;
> unsigned char * q = (unsigned char *) &c;
> q[3] = BitReverseTable256[p[0]];
> q[2] = BitReverseTable256[p[1]];
> q[1] = BitReverseTable256[p[2]];
> q[0] = BitReverseTable256[p[3]];
>
> Reverse an N-bit quantity in parallel in 5 * lg(N) operations:
>
> unsigned int v; // 32-bit word to reverse bit order
>
> // swap odd and even bits
> v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1);
> // swap consecutive pairs
> v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2);
> // swap nibbles ...
> v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4);
> // swap bytes
> v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8);
> // swap 2-byte long pairs
> v = ( v >> 16 ) | ( v << 16);
> For example.
>
> Dan
>
> See the Jumentum Network BASIC project
> http://jumentum.sourceforge.net/
> --- In l...@yahoogroups.com, "almagor100" wrote:
> >
> > Hi,
> > I'm using LPC2478.
> > My board connected to Analog Device ADE7878 chip that has Fast SPI that send continusly data.
> > Its 3 wire protocol that start the CS bit then clock out 7*32 bits (total 7*4 bytes=28 bytes) then raise the CS - wait 30Micro Second and start again.
> > The Clock is about 4mhz.
> > I want to fill a large area (in sdram) with the data.
> > I use the DMA with SSP and it works perfect.
> > I connect the CS line also to EINT0 so I know when the transfer is finished and then I reprogram the destinatin address for the DMA to fill the next block.
> > My problem is that the data is 32 bit - big endian (most first) and I need to swap the bytes to use them as a 32 bit integer.
> > Because I deal with a lot of data I don't want to waste time of this swap.
> > I read that the DMA has a bit for Big Endian mode. But when I set it on I don't get data at all (all 0).
> >
> > I belive I have misunderstood of the SBSIZE DBSIZE SWidth & DWidth in the DMACC1Control register.
> >
> > Any help?
> >
> > Regards,
> > Doron
>

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )