Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:31 13 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Problem with MM170 + WS2812 Csub + OPEN . . !

Author Message
PicFan
Senior Member

Joined: 18/03/2014
Location: Austria
Posts: 133
Posted: 12:36pm 12 Jun 2020
Copy link to clipboard 
Print this post

Hello everyone !

Many thanks to MatherP     for the "WS2812" CSUB! It all works perfectly,
but when I OPEN "COM2 ..." use, the LED control no longer works correctly - without data traffic.
All LEDs flicker and blink. The error always occurs with COM2.

Sporadic errors:
COM1 with interrupt and data traffic
IR - Interrupt
ON KEY. . .

Here is an example: MM170 V5.02.02 (current version)


OPTION DEFAULT NONE
OPTION EXPLICIT
 '
 
CONST  LED_PIN = 17       'pin to connect to the data-in on the WS2812
CONST  NUMLEDS = 08  'Number of LEDs in the WS2812 chain
SETPIN LED_PIN,DOUT    'Set the data pin as an output
 
DIM INTEGER colours(NUMLEDS)
DIM INTEGER  x
 
REM OPEN "COM2:4800" as #1    ' NO DATA TRAFFIC !!
 
DO
   FOR x = 0 to 7
     WS2812.setcolour(x,0,32,0)
     WS2812.pulses(NUMLEDS,LED_PIN,colours())
     PAUSE 100
     WS2812.setcolour(x,0,0,0)
   NEXT x
LOOP
 
 
SUB  WS2812.setcolour(led as integer, greenness as integer, redness as integer, blueness as integer)
         colours(led)= ((greenness and &HFF)<<16) + ((redness and &HFF)<<8) + (blueness and &HFF)
END SUB
 
Csub WS2812.Pulses
 00000000
 27BDFFB8 AFBF0044 AFBE0040 AFB7003C AFB60038 AFB50034 AFB40030 AFB3002C
 AFB20028 AFB10024 AFB00020 3C169D00 8EC20000 3C120032 3652DCD5 8C420000
 3C100026 261025A0 0052001B 024001F4 3C13002B 367398B7 3C110057 2631316E
 AFA5004C 0080A821 8EC30028 8CA40000 AFA60050 00009012 2652FFFF 0050001B
 020001F4 00008012 2610FFFF 0053001B 026001F4 00009812 0051001B 022001F4
 0060F809 00008812 8EA50000 8EC30040 000520C0 00052940 00A42023 24050001
 00452804 0060F809 AFA50018 AFA20010 8EA30000 8EC20040 8FB40010 000320C0
 00031940 0040F809 00642023 0040F021 8FA2004C 24050006 8C440000 8EC20024
 0040F809 03C0B821 8FA3004C AFA20014 8EC20024 8C640000 0040F809 24050005
 8EA30004 1C600006 8FAA0050 1460003F 3C040008 8EA30000 5060003D 3C03BF88
 00006021 10000032 00002021 2463FFFF 25290001 2508FFFF 24E70001 24C60001
 8D450004 8D440000 00035827 00057040 016E7004 00642006 00652807 306B0020
 01C42025 00AB200B 30840001 10800004 00602821 A0F30000 10000003 A0D20000
 A0F10000 A0D00000 1580000A 00000000 14AD0008 00000000 82840000 28850005
 14A00003 2484FFFC 1000FFE0 A2840000 A2800000 0501FFDD 01202021 8EA50004
 258C0001 000C1FC3 0065282A 14A00008 254A0008 8EA50004 54A3000C 3C040008
 8EA30000 0183302B 50C00008 3C040008 24890001 02843821 02E43021 24080016
 24030017 1000FFCE 240D0017 3C03BF88 AC641064 3C03BF88 AC601068 8EA40000
 00001821 000428C0 00042140 00854823 40834800 8FA70018 8FA40014 00003021
 AC870000 8FA50014 00C04021 ACA70000 8FA50010 00A62021 80840000 00641821
 40044800 0064282B 10A0FFFD 00000000 AC470000 03C81821 80630000 24C60001
 00832021 40034800 0064282B 14A0FFFD 00000000 0126202A 5080FFEB 8FA50014
 8FA40018 3C030008 AC440000 8FBF0044 3C02BF88 AC431064 3C02BF88 8FBE0040
 8FB7003C 8FB60038 8FB50034 8FB40030 8FB3002C 8FB20028 8FB10024 8FB00020
 AC431068 03E00008 27BD0048
End Csub


Thank you and a nice weekend !

Wolfgang
Edited 2020-06-12 22:41 by PicFan
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10575
Posted: 01:03pm 12 Jun 2020
Copy link to clipboard 
Print this post

On the MM2 COM2 works by setting up a timer that fires an interrupt at three times the baudrate. This will completely mess up the WS2812 timing. You need to close com2 before using the csub and the re-open after
 
PicFan
Senior Member

Joined: 18/03/2014
Location: Austria
Posts: 133
Posted: 10:04am 13 Jun 2020
Copy link to clipboard 
Print this post

Thanks, yes that is the only solution, also for the sporadic errors.

Wolfgang
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025