ArmMiteF4 BITBANG BITSTREAM Operation


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2247
Posted: 05:23am 22 Mar 2024      

A more accurate way to get the 4.5mS pause. The other was dependant on the CPU speed of the F4.
Do
'Your program here.
 Input "Enter Device and Key codes "; dev, key
 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
Math set 14 , d() '13=1000/(38*2)uS duration of a half cycle @ 38kHz

BitBang bitstream IRpin, 670, c() 'send 9ms start 38kHz
Timer =0
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
Do : Loop Until Timer > 4.3
BitBang bitstream IRpin, 1387, d() 'send the data

Pin(IRpin) = 0
End Sub

Edited 2024-03-22 15:24 by phil99