RISC DMA transfers from hell !!!! 
Author Message
 RISC DMA transfers from hell !!!!

Hey,
  I'm trying to write a simple driver block in simulink for the BT878
video capture chip from Brooktree, as part of a summer project before
i go back to university. Everything seems to be going great except for
the fact that i just can't figure how to set up the DMA transfers!!!!
The chip works by, first: collecting the data from the camera,
processing it, and passing it into a FIFO buffer. Secondly the DMA
controller takes the information from this and then writes it to a
certain place in memory.
  The problem lies in the fact that for the DMA controller to do this
it must be given a set of instructions written in its own assembler
code, of which there are only about 6 opcodes -cool. What i just can't
figure is how to pass these instructions from a C program (x86) and
how to denoted these instructions in the coding. I have already tried
simply writing them out long hand in binary and then converting them
back to hex, but some of the instructions can get very long (5
DWords!!!!) + i need to be able to alternate oprands so that different
areas of memory can be accessed!!!! I dont yet have a problem getting
the controller to read the instructions. I was thinking that i could
possibly set up some sort of struct for each instruction, but, i'm not
to sure how C would convert that, ie bit order, and all that stuff.
Please help... Steve Henry


Sat, 10 Jan 2004 21:12:49 GMT  
 RISC DMA transfers from hell !!!!


Quote:
>   The problem lies in the fact that for the DMA controller to do this
> it must be given a set of instructions written in its own assembler
> code, of which there are only about 6 opcodes -cool. What i just can't
> figure is how to pass these instructions from a C program (x86) and

This isn't a C language question, it is a C compiler question and not on-
topic here.


Sat, 10 Jan 2004 21:50:55 GMT  
 RISC DMA transfers from hell !!!!

Quote:

>   I'm trying to write a simple driver block in simulink for the BT878
> video capture chip from Brooktree, as part of a summer project before
> i go back to university. Everything seems to be going great except for
> the fact that i just can't figure how to set up the DMA transfers!!!!
> The chip works by, first: collecting the data from the camera,
> processing it, and passing it into a FIFO buffer. Secondly the DMA
> controller takes the information from this and then writes it to a
> certain place in memory.

<snip>

Quote:
> I was thinking that i could
> possibly set up some sort of struct for each instruction, but, i'm not
> to sure how C would convert that, ie bit order, and all that stuff.

Steve...

Sounds like an interesting project; but you're asking in the wrong place.

comp.lang.c deals with the C /language/ (as opposed to solving particular
problems with it)
--
Morris Dovey
West Des Moines, Iowa USA
Available for embedded C contract work



Sat, 10 Jan 2004 22:31:47 GMT  
 RISC DMA transfers from hell !!!!

Quote:

>   I'm trying to write a simple driver block in simulink for the BT878
> video capture chip from Brooktree, as part of a summer project before
> i go back to university. Everything seems to be going great except for
> the fact that i just can't figure how to set up the DMA transfers!!!!
> The chip works by, first: collecting the data from the camera,
> processing it, and passing it into a FIFO buffer. Secondly the DMA
> controller takes the information from this and then writes it to a
> certain place in memory.
>   The problem lies in the fact that for the DMA controller to do this
> it must be given a set of instructions written in its own assembler
> code, of which there are only about 6 opcodes -cool. What i just can't
> figure is how to pass these instructions from a C program (x86) and
> how to denoted these instructions in the coding. I have already tried
> simply writing them out long hand in binary and then converting them
> back to hex, but some of the instructions can get very long (5
> DWords!!!!) + i need to be able to alternate oprands so that different
> areas of memory can be accessed!!!! I dont yet have a problem getting
> the controller to read the instructions. I was thinking that i could
> possibly set up some sort of struct for each instruction, but, i'm not
> to sure how C would convert that, ie bit order, and all that stuff.

Steve...


--
Morris Dovey
West Des Moines, Iowa USA
Available for embedded C contract work



Sat, 10 Jan 2004 23:22:55 GMT  
 RISC DMA transfers from hell !!!!

Quote:
> Steve...



Minor typo fixed.


Sat, 10 Jan 2004 23:27:06 GMT  
 RISC DMA transfers from hell !!!!

Quote:

>   I'm trying to write a simple driver block in simulink for the BT878
> video capture chip from Brooktree, as part of a summer project before
> i go back to university.

Steve...


--
Morris Dovey
West Des Moines, Iowa USA
Available for embedded C contract work



Sat, 10 Jan 2004 23:26:37 GMT  
 RISC DMA transfers from hell !!!!



Quote:
> Hey,
>   I'm trying to write a simple driver block in simulink for the
BT878
> video capture chip from Brooktree, as part of a summer project
before
> i go back to university. Everything seems to be going great except
for
> the fact that i just can't figure how to set up the DMA
transfers!!!!
> The chip works by, first: collecting the data from the camera,
> processing it, and passing it into a FIFO buffer. Secondly the DMA
> controller takes the information from this and then writes it to a
> certain place in memory.
>   The problem lies in the fact that for the DMA controller to do
this
> it must be given a set of instructions written in its own
assembler
> code, of which there are only about 6 opcodes -cool. What i just
can't
> figure is how to pass these instructions from a C program (x86)
and
> how to denoted these instructions in the coding. I have already
tried
> simply writing them out long hand in binary and then converting
them
> back to hex, but some of the instructions can get very long (5
> DWords!!!!) + i need to be able to alternate oprands so that
different
> areas of memory can be accessed!!!! I dont yet have a problem
getting
> the controller to read the instructions. I was thinking that i
could
> possibly set up some sort of struct for each instruction, but, i'm
not
> to sure how C would convert that, ie bit order, and all that
stuff.
> Please help... Steve Henry

Steve, I will and can only answer the tiny C-part of your question
here:
(this assumes the number of bits in a byte is the same in the dma
and the c-implementation, otherwise you will have to fiddle around a
lot with bitshifts)
Set up some sort of struct as you planned yourself, like (just an
example)

struct
{
    unsigned char opcode[2];
    unsigned char operand_1[4];
    unsigned char operand_2[6];
.
.
.

Quote:
}move;

struct
{
    unsigned char opcode[3];
    unsigned char operand_1[8];
    unsigned char operand_2[8];
.
.
.
Quote:
}add;

and so on for the different instructions.
initialize the structs with opcode, like in

move.opcode[0] = 0x23;
move.opcode[1] = 0x45;
and so on (assuming the opcode doesn't change for the same
instruction, but if for the same operation there are some
modification bits you can use bitwise or/and to set/clear them)

where appropriate in your code, load the other members of the struct
with operands etc, char by char or using memcpy()
and then memcpy the members of the struct into an array of unsigned
char and send it to the dma (you said this (off topic) part is
already working)

unsigned char bin_command[<whatever size you need>];
memcpy(bin_command, move.opcode, sizeof move.opcode);
memcpy(bin_command + sizeof move.opcode, move.operand_1, sizeof
move.operand_1);
send_to_dma(bin_command); /*yor already working send*/

nb, if the bit order in the dma is different from that in the
implementation you can use bitwise and to isolate bits from the
struct members and bitwise or to set them in the output bitstream.

Try to work that part out in pure standard C, and if you have
problems with it (the C-part _only_), come here again.

HTH
-- .
Robert Stankowic



Sat, 10 Jan 2004 23:41:04 GMT  
 RISC DMA transfers from hell !!!!

Quote:
>unsigned char bin_command[<whatever size you need>];
>memcpy(bin_command, move.opcode, sizeof move.opcode);
>memcpy(bin_command + sizeof move.opcode, move.operand_1, sizeof
>move.operand_1);
>send_to_dma(bin_command); /*yor already working send*/

a further refinement would be to define a function or #define for each
assembler instruction and hide the formatting of an instruction inside
that

since you can write an assembler in c
you can get quite elaborate with symbolic labels and everything elkse if
you want



Sun, 11 Jan 2004 01:34:34 GMT  
 RISC DMA transfers from hell !!!!

Quote:



> Minor typo fixed.

Mark...

Thanks!
--
Morris



Sun, 11 Jan 2004 02:12:56 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. dma transfer, (sound blaster, specifically)

2. DMA Transfers

3. DMA transfer

4. Programming DMA transfer in Visual C++ 4.2

5. RISC as the making of UNIX (Re: RISC bashing at USENIX)

6. From DLL Hell to Gacutil Hell

7. Using Interrupts and DMA transfers within Windows 95, NT?

8. RISC vs CISC or SunOS

9. gcc/gas support for PA-RISC 2.0

10. Question about DEC's optimizing compilers in RISC ULTRIX

11. CFORTRAN release for RISC Mips

12. Crash a RISC machine from user-mode code:

 

 
Powered by phpBB® Forum Software