Help with PIC16F84A for Beginners - Multiply, Divide, SQRT

  • Thread starter Thread starter Em Jay
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
Em Jay
Messages
15
Reaction score
0
hello

i am a beginner in pic16f84a
and i found it very exciting but there is a problem i need u to help me with


suppose that portb is input


how can i copy the input to all GPR register


and one more question
what is the best type of Microcontroler that got more instructio than pic1684a

i mean sqrt and dived and multiply


and thanks
 
Engineering news on Phys.org
If you're using assembler, you can copy from one memory location (e.g. PORTB) to another (e.g. 0x0C, the first GPR location) using the MOVF command. To move it into ALL the GPRs, you'd just have to loop that 68 times (assuming you'd want to do so).
http://ww1.microchip.com/downloads/en/devicedoc/35007b.pdf

To my knowledge, there are no (simple and without math coprocessor) microcontrollers that have the higher math functions you're looking for. Some of the PIC18s have the ability to do multiplication, but there were some restrictions on use--consult a datasheet. Unfortunately, you'll have to devise your own scheme (or find libraries where people have made them) to do these sorts of operations. As a hint, it's easy to divide and multiply by powers of 2 merely by bit shifting left or right. You can also do it the hard way by adding things together (e.g. 20 x 5 = 20 + 20 + 20 +20 + 20) or subtracting (e.g. 101 / 20 = 101 - 20 - 20 - 20 - 20 - 20, with 1 left over).

Good luck!