![]() I was short of flash space so the reduced code was more important to me. ( cpfseq = 1 or 2 cyles ? not sure, have not tested with mplab sim) I did quite a few simulations like the above to check that my code would always end up with a correct 16 bit result. My code was pretty much copied from one of the PID application notes. Just doing a quick check of what the result will be if you get an overflow (at various points in time) while you are reading the two registers, looks OK to me.įF 01 movff POSCNTH,PositionH PositionH = 01Ġ0 02 movff POSCNTL,PositionL PositionL = 00Ġ0 02 cpfseq PositionH W = 02, PositionH = 01Ġ0 02 movff POSCNTL,PositionL not skipped PositionL = 00Ġ0 02 movwf PositionH PositionH = 02 Final result = 02 00 correct.įF 01 movff POSCNTL,PositionL PositionL = FFĠ0 02 cpfseq PositionH W = 01, PositionH = 01Ġ0 02 movwf PositionH PositionH = 01 Final result = 01 FF correct.įF 01 cpfseq PositionH W = 01, PositionH = 01
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |