[sdiy] Using 8051 to build a synth

Jason Tribbeck jason.tribbeck at argogroup.com
Thu Aug 19 11:44:27 CEST 2004


Hi,

> What I can see the potential difficulty in using 8051 as a
> multiplier is that I
> would need 2 (8-bit max)AD converter to sample the multiplied
> inputs and then
> move the data to 2 seperate registers then multiply the 2
> registers for the
> outcome then output to an AD converter? Would there be enough
> pins (any left)to
> do anything else?Also, the acc is only 8 bit wide?

You use mutliple bytes to form the answer (as you would for any smaller
micro, such as the 6502 (of which I am particularly fond)).

The A/D convertors are 12-bit.

The D/A convertors are 12-bit too.

With 100 pins in total, there's plenty of other things you can do (there's 2
UARTs - useful for MIDI, for example; an SPI bus - if you wanted to have
increased D/A accurracy).

However, the drawbacks with this particular device are:

1) It's TQFP, which makes prototyping a little more complicated than with
normal DIL chips

2) It's 3v, so using your 5v logic chips requires level convertors

> BTW, I think you guys are an AWSOME bunch!!!!! :)

I think the analogue chappies are awesome - programming's a little easier
than working out how to make an exponential log circuit from transistors :)

> Looking forward to be learning from you knowledgeble chaps!!!!!

I wouldn't say I was knowledgeable - I've not programmed an 8051 for a long
while, and I'd only spent about a week on it! I can tell a good device from
its datasheet though :)

I was looking at the datasheet for the device. There are memory registers
for the multiply, so you stick A into one set of memory locations, B into
another set of memory locations, wait a bit, and pull the answer from
another set of memory locations.

>From the C8051F120 datasheet:

The example below implements the equation:

(0.5 x 2.5) + (0.5 x -2.5) = 0.125 - 0.125 = 0.0

MOV MAC0CF, #0Ah ; Set to Clear Accumulator, Use fractional numbers
MOV MAC0AH, #40h ; Load MAC0A register with 4000 hex = 0.5 decimal
MOV MAC0AL, #00h
MOV MAC0BH, #20h ; Load MAC0B register with 2000 hex = 0.25 decimal
MOV MAC0BL, #00h ; This line initiates the first MAC operation
MOV MAC0BH, #E0h ; Load MAC0B register with E000 hex = -0.25 decimal
MOV MAC0BL, #00h ; This line initiates the second MAC operation
NOP
NOP ; After this instruction, the Accumulator should be equal to 0,
    ; and the MAC0STA register should be 0x04, indicating a zero
NOP ; After this instruction, the Rounding register is updated

The example below implements the equation:

4660 x -292 = -1360720

MOV MAC0CF, #01h ; Use integer numbers, and multiply only mode (add to zero)
MOV MAC0AH, #12h ; Load MAC0A register with 1234 hex = 4660 decimal
MOV MAC0AL, #34h
MOV MAC0BH, #FEh ; Load MAC0B register with FEDC hex = -292 decimal
MOV MAC0BL, #DCh ; This line initiates the Multiply operation
NOP
NOP ; After this instruction, the Accumulator should be equal to
    ; FFFFEB3CB0 hex = -1360720 decimal. The MAC0STA register should
    ; be 0x01, indicating a negative result.
NOP ; After this instruction, the Rounding register is updated

--
Jason Tribbeck      Director of Research and Technology        Argogroup




More information about the Synth-diy mailing list