Help with PIC16F84A for Beginners - Multiply, Divide, SQRT

  • Thread starter Thread starter Em Jay
  • Start date Start date
Click For Summary
To copy input from PORTB to all General Purpose Registers (GPRs) in the PIC16F84A, use the MOVF command in assembler and loop through the GPRs as needed. For advanced mathematical functions like square root, division, and multiplication, the PIC16F84A lacks built-in support, and alternatives like the PIC18 series may offer some capabilities but come with limitations. Users are encouraged to explore libraries or develop custom algorithms for these operations. Simple methods for division and multiplication can be achieved through bit shifting or repeated addition and subtraction. Overall, the PIC16F84A is limited in advanced mathematical functions, requiring creative solutions for such tasks.
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!
 
I am trying to understand how transferring electric from the powerplant to my house is more effective using high voltage. The suggested explanation that the current is equal to the power supply divided by the voltage, and hence higher voltage leads to lower current and as a result to a lower power loss on the conductives is very confusing me. I know that the current is determined by the voltage and the resistance, and not by a power capability - which defines a limit to the allowable...

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
8
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
3
Views
3K