Help with PIC16F84A for Beginners - Multiply, Divide, SQRT

  • Thread starter Thread starter Em Jay
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on programming the PIC16F84A microcontroller, specifically how to copy input from PORTB to all General Purpose Registers (GPRs) using the MOVF command in assembly language. It highlights that to achieve this, a loop must be implemented to move the data into each GPR location. Additionally, the conversation addresses the limitations of the PIC16F84A regarding advanced mathematical functions such as square root, division, and multiplication, suggesting that while some PIC18 models offer multiplication capabilities, users may need to create their own algorithms or utilize existing libraries for complex operations.

PREREQUISITES
  • Understanding of PIC16F84A microcontroller architecture
  • Familiarity with assembly language programming
  • Knowledge of memory addressing and GPRs
  • Basic concepts of bit manipulation for arithmetic operations
NEXT STEPS
  • Research the MOVF command in PIC assembly language
  • Explore the capabilities of PIC18 microcontrollers for advanced mathematical functions
  • Learn about creating algorithms for multiplication and division in assembly
  • Investigate existing libraries for mathematical operations on microcontrollers
USEFUL FOR

This discussion is beneficial for beginners in embedded systems, hobbyists working with PIC microcontrollers, and developers seeking to implement arithmetic functions in assembly language.

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!
 

Similar threads

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