local pwmfrequency local pwmdutycycle local rollvalue local divisor = 4 local mbwrite = MB.W local t = 0 outPin = 0 LJ.IntervalConfig(1, 1000) while true do if LJ.CheckInterval(1) then if t <= 5 then pwmdutycycle = 1 pwmfrequency = 2 rollvalue=(80000000/pwmfrequency)/divisor mbwrite(44000,1,0) --disable dio0 pin mbwrite(44900,0,0) --disable clock0 mbwrite(44100,1,0) --pwm index mode mbwrite(44901,0,divisor) --divisor mbwrite(44904,1,rollvalue) --pwmrollvalue mbwrite(44300,1,rollvalue*pwmdutycycle/100) --config A mbwrite(44000,1,1) --enable dio0 pin mbwrite(44900,0,1) --enable clock0 print("On FIO0 a ", pwmfrequency, "Hz signal at a ", pwmdutycycle, "% duty cycle has been generated") t = t+1 print(t) end if t >= 6 then mbwrite(44000,1,0) --disable dio0 pin mbwrite(44900,0,0) --disable clock0 pwmdutycycle = 55 rollvalue = 40000000 pwmfrequency = (80000000/(rollvalue*divisor)) mbwrite(44100,1,0) --pwm index mode mbwrite(44901,0,divisor) --divisor mbwrite(44904,1,rollvalue) --pwmrollvalue mbwrite(44300,1,(rollvalue*pwmdutycycle)/100) --config A mbwrite(44000,1,1) --enable dio0 pin mbwrite(44900,0,1) --enable clock0 print("On FIO0 a ", pwmfrequency, "Hz signal at a ", pwmdutycycle, "% duty cycle has been generated") t = t+1 print(t) end if t >= 16 then t=0 end end end