Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

A problem with PIC16F876 and some function

Status
Not open for further replies.

diego101

Newbie level 2
Joined
Jun 23, 2003
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
18
A problem with PIC16F876

I have to realize the function

(X-18000)*(4095/22000)

with a PIC16F876.
X is in the range 18000-40000.
Anyone can help me please!?Thanks!!!!!!
 

Which language are you planing to use?

In C this is easy if you do not have a problem with codesize ...

In assembler this will not be sooo easy.

In Assembler you could work like this:
shift your two bytes number (that you want to multiply by 4095) 4 bits to the left (which is a multiplication by 16) now you have a three bytes result. Now add a fourth byte 0x00 byte to your three bytes (you would have to shift your number 8 bits to the left which can be eliminated by just adding another 0x00 byte to the end of your result) which gives you a 4 bytes result (your original number multuplied by 4096) next subtract your original number, now you have an intermediate result (your original number multiplied by 4095).

Afterwards use this:
http://www.piclist.com/techref/microchip/math/div/div16or32by16to16.htm

to do the division by 22000 :)

hope this helps
 

FOR C-MAN

I'm using ASSEMBLER!
To program the PIC16F876 i can use only the ASSEMBLER!!
Could you help me!?It's very important!!
Thank you!!
 

Use a C compiler to build your assembler code !

NeuralC
 

I did not want to suggest this because the assembler code which is generated for example by Hi-Tech C is in no way compatible with Mplab.

Also if you use high optimization (in Hi-Tech) the code is very hard to understand and integrate into another application ...

But it could be a point to start :)

best regards
 

An Easy Solution

Use the the document for the implementation of the following FIXED POINT routines:

- Addition
- Subtraction
- Multiplication
- Division
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top