PDA

View Full Version : MUXC for debugging purposes, trying but not working



peterz
01-31-2007, 03:44 AM
I have tried to generate a continuous·pulse of 1us on PIN0.
For this I have tried to use MUXC, as follows:

Test0
······················· ror···· mask_bits,#1 wc
······················· muxc··· outa,debug_mask
······················· mov t1, bitticks
······················· add t1, cnt
:WaitTick
······················· cmps t1,cnt wc
······················· if_nc jmp #:WaitTick
······················· jmp #Test0

debug_mask····· LONG %0000_0000_0000_0000_0000_0000_0000_0001
mask_bits········ LONG %1010_1010_1010_1010_1010_1010_1010_1010
bitticks············ LONG 80

Note: in my Spin code section I set PIN0 as OUTPUT.

However I dont get any pulse at all! I suppose my code is wrong, is it?

·

Mike Green
01-31-2007, 03:57 AM
The only obvious error is the use of a signed compare (cmps). CNT is an unsigned 32 bit count. If you happen to run this when the value has its sign bit set, the :WaitTick loop will hang for maybe 2^31 clock ticks which can be a substantial part of a minute. Better to use cmp or waitcnt which will work on unsigned values. Your use of MUXC looks fine.