It seems the F4 Bitbang Bitstream won't accept times greater than 3000uS so the 4500uS value gets corrupted. So something seems to be wrong. Also the modulation frequency is a little higher (39.8kHz) than for the Pico so the duration of the half-cycles has been increased from 13 to 14uS. Now it is a little low but close enough.
The apparently wrong timing pointed out by Volhout are correct on my scope and the Sub works on my devices. Perhaps a display artefact in the images?
'Work-around for problems with Bitbang Bitstream on F4 Const IRpin = MM.Info(pinno PA0) 'output pin, change as needed SetPin IRpin, dout : Pin(IRpin) = 0 ' IR code output
Do 'Your program here. NECsend IRpin, dev, key Loop
Sub NECsend IRpin As integer, dev As integer, key As integer 'Version for ARMmite F407 MMBasic Version 5.07.02b2 Local integer word, d(1389), m, n = 1, c(671)
word = (dev<<16) + (key<<8) + 255-key 'assemble 32 bits
Math set 14 , c() '13=1000/(38*2)uS duration of a half cycle @ 38kHz 9mS start burst Math set 14 , d() '13=1000/(38*2)uS duration of a half cycle @ 38kHz main bitstream
BitBang bitstream IRpin, 670, c() 'send 9ms start 38kHz Pause 1.5 '4.5mS pause after start pulse train - allowing for 3mS processing delays @ 168MHz CPU
For m = 43 To 1387 Step 42 'load data after start sequence d(m) = (((word>>(32-n)) AND 1)*2 + 1) * 562.5 'convert bits to duration (short = 0, long = 1) Inc n 'step to next data bit Next
BitBang bitstream IRpin, 1387, d() 'send the data
Pin(IRpin) = 0 End Sub
Footnote added 2024-03-22 15:02 by phil99 Missed a line in the Do Loop.