Help with PIC16F84A for Beginners - Multiply, Divide, SQRT

  • Thread starter Em Jay
  • Start date
In summary, the conversation discusses using assembler to copy input from PORTB to GPR registers, looping the process 68 times. It also mentions that there are no microcontrollers with built-in higher math functions, and suggests devising a scheme or finding libraries to perform these operations. The conversation ends with a good luck message.
  • #1
Em Jay
15
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
  • #2
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!
 

What is the PIC16F84A and why is it important for beginners?

The PIC16F84A is a microcontroller developed by Microchip Technology. It is often used by beginners to learn about microcontrollers and embedded systems due to its simplicity and low cost.

How do I multiply and divide using the PIC16F84A?

The PIC16F84A has built-in instructions for multiplication and division. To multiply, you can use the MULT instruction and to divide, you can use the DIV instruction. These instructions take two operands and store the result in a designated register.

Can the PIC16F84A perform square root calculations?

Unfortunately, the PIC16F84A does not have a built-in instruction for square root calculations. However, there are libraries and algorithms available that can be implemented to calculate square roots using the microcontroller.

Are there any limitations to using the PIC16F84A for arithmetic operations?

The PIC16F84A is an 8-bit microcontroller, so it can only perform arithmetic operations on 8-bit numbers. This means that the largest number that can be multiplied or divided is 255, and the largest number that can be squared is 65,025.

Where can I find resources to help me learn more about using the PIC16F84A for arithmetic operations?

There are many online resources, tutorials, and forums available that can help you learn more about using the PIC16F84A for arithmetic operations. You can also refer to the official datasheet and programming manual provided by Microchip Technology for detailed information on the microcontroller's capabilities and instructions.

Similar threads

  • Programming and Computer Science
Replies
2
Views
2K
  • Electrical Engineering
Replies
8
Views
862
Replies
8
Views
1K
  • Electromagnetism
Replies
16
Views
989
  • Electrical Engineering
Replies
12
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
533
  • Classical Physics
Replies
7
Views
744
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
Replies
6
Views
3K
Back
Top