+ Post New Thread

Results 1 to 4 of 4

- 13th January 2009, 11:01 #1

- Join Date
- Aug 2007
- Location
- PAKISTAN
- Posts
- 77
- Helped
- 2 / 2
- Points
- 1,606
- Level
- 9

## 16 bit division asm for 80c51

hello forum!

i want to convert the data i am getting from adc ic into voltage .if the data reaches ff it means we have 5v and so on.so the formula should be (adc_data*5)/ff how to write the code in assembly i can do it in c and bascom but i need to do it in assembly please help

- 13th January 2009, 11:01

- 13th January 2009, 15:06 #2

- Join Date
- Oct 2004
- Location
- West Coast
- Posts
- 7,942
- Helped
- 2317 / 2317
- Points
- 74,061
- Level
- 66

## Re: 8051 assembly question

Create a look-up-table and use the MOVC A, @A+DPTR instruction ..

Here is an example:

http://www.8052.com/faqs/119923

Rgds,

IanP

- 13th January 2009, 15:06

- 13th January 2009, 18:52 #3

- Join Date
- Apr 2008
- Location
- Nasik
- Posts
- 150
- Helped
- 31 / 31
- Points
- 2,536
- Level
- 11

## Re: 8051 assembly question

u can calculate it, i guess ur using 8-bit adc with Vref+ as 5v and Vref- as 0v

so the step size is approx 20mv,

use two ram location say voltage_msb and voltage_lsb, where the voltage is stored in milli volts in BCD format. decrement the adc reading by 1 and add 20 to it keep repeating this loop till the adc reading becomes 0.

This method is much simpler are less tedious than making a lookup table

check :

http://www.dnatechindia.com/index.php/Code-Library/

for sample 8051 codes

- 13th January 2009, 18:52

- 15th January 2009, 09:29 #4

- Join Date
- Jan 2009
- Location
- Pakistan
- Posts
- 126
- Helped
- 10 / 10
- Points
- 1,937
- Level
- 10

## 8051 assembly question

You can place the ADC_DATA in a ACC and the number (05h) in (B) register and use the multiply instruction (mul a,b) for multiplication and after the execution of this instruction you get the result in accumulator. and for division move the number (#0ffh) in (B) register and use (div a,b). if your result of multiplication is greater then 8 bits then your result will be placed in A and B registers and you should take care of it. you should handle the 16 bit division in 2 steps. like divide the number by 2,4 to bring it in the range of 8 bits. by shifting right and divide them in 2 or 4 steps.

+ Post New Thread

Please login