Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

10: It's an Analog World > Exercises - Pg. 189

It's an Analog World 189 configuration of the many possible and only a few of the advanced features available. We have tested our newly acquired capabilities with two types of analog inputs available on the Explorer16 board and hopefully we had some fun in the process. Notes for the C Experts Even if the PIC24 has a fast divide instruction, there is no reason to waste any processor cycles. In embedded control, every processor cycle is precious. If the divisor is a power of two, the integer division can be best performed as a simple shift right by an appropriate number of positions with a computational cost that is at least an order of magnitude smaller than a regular division. If the divider is not a power of two, consider changing it if the application allows. In our last example, we could have opted for averaging 10 temperature samples, or 15 as well as 20, but we chose 16 because this made the division a simple matter of shifting the sum by 4 bits to the right (in a single-cycle PIC24 instruction). Tips & Tricks If the sampling time required is longer than the maximum available option (32 Tad) you can try and extend Tad first or, better, swap things around and enable the automatic sampling