ArmMiteF4 BITBANG BITSTREAM Operation


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1910
Posted: 07:00am 22 Mar 2024      

Thankyou for such prompt attention. Not serious issues as there are simple ways to cope with both.

Yet another revision. Array c() is unnecessary.
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
Local integer word, d(1389), m, n = 1

word = (dev<<16) + (key<<8) + 255-key 'assemble 32 bits

Math set 14 , d() '13=1000/(38*2)uS duration of a half cycle @ 38kHz

BitBang bitstream IRpin, 670, d() '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 17:09 by phil99

Footnote added 2024-03-24 07:25 by phil99
In the event that the program using the NECsend Sub is also using the Timer odd things may hapen when the Sub resets it. These mods fix that.
T = Timer + 4.3
For
...
Next
Do : Loop Until T < Timer


Footnote added 2024-03-24 07:30 by phil99
Also add this line.
Local Float T