Code:
DEFINE  OSC	20
DEFINE ADC_BITS 10
DEFINE ADC_SAMPLEUS 25
INCLUDE "MODEDEFS.BAS"
intcon.7=1:memcom.7=1: pspcon.4:trisd=$ff:channel var byte
outputab var bit:ch_onoff var bit:sysen var bit:channel=0: outputab=0
ch_onoff=0:sysen=0
loop:
channel=portd:channel=channel & $1F: outputAB=portd.5:ch_onoff=portd.6
sysen=portd.7:pause 500
serout portb.4,n9600,["Channel = ",#channel,13,"Output AB ",#outputAB,13,"Channel ON/OFF = ",#ch_onoff,13,"SYSEN = ",#SYSEN,13]
goto loop
end
Which revision of the '8720 do you have?
The early ones had REAL, documented problems running above 4Mhz. The problems varied and depended mainly on the code running, some things worked fine, others didn't. Try running your program at 4Mhz or less once and see if it works.
I had issues with the early ones awhile back, couldn't figure it out. Read the errata sheets about the 4Mhz problem. Tried running programs at both 4Mhz and 10Mhz...4Mhz worked, 10Mhz didn't, and this was only blinking LEDs.
After I got a few of the new revisions, the problems went away.
And I simplified your program a bit...