devonsc
Advanced Member level 4

example multiply pic assembler
Hi there, again, me and my "lousy" questions regarding PIC microcontroller.
I would like to ask about programming a multiplication and division in PIC. I've come across reading materials as well as opinions from the smart ones that it can be done using various ways. Please correct me if I'm wrong:
a.) Through repeated addition and subtraction - Slow but it seems to be easy to me
b.) Through look-up tables - Fast but take up a lot of memory?
c.) Through somekind of shifting method? - I've read about this but really don't quite understand how it can be done.
I was thinking to do the following:
I'm trying to write a PWM code in PIC that varies according to an analogue input which I will feed the PIC through the ADC module. I was thinking to have the PIC to perform some calculation based on this analogue input and changes the my CCPR1L and CCP1CON value for the PWM. Any advice? Any guidance is very much needed. Thanks in advance.
By the way, I still don't quite understand how do I store a 10-bit value. I was trying to store the 2 LSB of my calculation result, bit-0 and bit-1 on a location to have it stored in CCP1CON later and the others on another location to have it stored in CCPR1L later. Is this possible? Help very much needed. Thanks in advance.
Hi there, again, me and my "lousy" questions regarding PIC microcontroller.
I would like to ask about programming a multiplication and division in PIC. I've come across reading materials as well as opinions from the smart ones that it can be done using various ways. Please correct me if I'm wrong:
a.) Through repeated addition and subtraction - Slow but it seems to be easy to me
b.) Through look-up tables - Fast but take up a lot of memory?
c.) Through somekind of shifting method? - I've read about this but really don't quite understand how it can be done.
I was thinking to do the following:
I'm trying to write a PWM code in PIC that varies according to an analogue input which I will feed the PIC through the ADC module. I was thinking to have the PIC to perform some calculation based on this analogue input and changes the my CCPR1L and CCP1CON value for the PWM. Any advice? Any guidance is very much needed. Thanks in advance.
By the way, I still don't quite understand how do I store a 10-bit value. I was trying to store the 2 LSB of my calculation result, bit-0 and bit-1 on a location to have it stored in CCP1CON later and the others on another location to have it stored in CCPR1L later. Is this possible? Help very much needed. Thanks in advance.