1. I need to interface STM8S003F3 with WS2811. I want to know if external crystal is required for it or not, as WS2811 has very tight timings. I prefer to generate timing through NOP's for delay using inline functions
2. As STM8S003F3, Accuracy of Internal oscillator = +-5% over all temperature ranges.
3. WS2811 specifies:
a) T0H = 0.5μs ±150ns
b) T1H = 1.2μs ±150ns
c) T0L = 2.0μs ±150ns
d) T1L = 1.3μs ±150ns
e) RES = Above 50μs
4. With 16Mhz crystal, time for NOP is 1/16Mhz = 0.0625us
With on left end of accuracy -5%, time for NOP is 1/(16*.95) = 65.79ns
With on right end of accuracy +5%, time for NOP is 1/(16*1.05) = 59.52ns
5. Are below calculations for NOP's are ok? I think internal oscillator can also be used.
6. a) T0H = 0.5μs ±150ns
variation allowed around 0.5us is +-150ns i.e = 0.35us to 0.65us
NOP's in T0H = 0.5μs / 0.0625us = 8
Taking 8 NOP will generate = 0.5us
variation with +5% accuracy = 8 * 59.52ns = 0.476us
variation with -5% accuracy = 8 * 65.79ns = 0.526us
So well within specs here
b) T1H = 1.2μs ±150ns
variation allowed around 1.2us is +-150ns i.e = 1.05us to 1.35us
NOP's in T1H = 1.2μs / 0.0625us = 19.2
Taking 19 NOP will generate = 1.1875us
variation with +5% accuracy = 19 * 59.52ns = 1.131us
variation with -5% accuracy = 19 * 65.79ns = 1.25us
So well within specs here
c) T0L = 2.0μs ±150ns
variation allowed around 2.0us is +-150ns i.e = 1.85us to 2.15us
NOP's in T0L = 2.0μs / 0.0625us = 32
Taking 32 NOP will generate = 2.0μs
variation with +5% accuracy = 32 * 59.52ns = 1.905us
variation with -5% accuracy = 32 * 65.79ns = 2.105us
So well within specs here
d) T1L = 1.3μs ±150ns
variation allowed around 1.3us is +-150ns i.e = 1.15us to 1.45us
NOP's in T1L = 1.3μs / 0.0625us = 20.8
Taking 21 NOP will generate = 1.3125μs
variation with +5% accuracy = 21 * 59.52ns = 1.25us
variation with -5% accuracy = 21 * 65.79ns = 1.382us
So well within specs here
e) RES = Above 50μs
So number of NOP's should be so that,
at minimum clock time it should have at-least 50us
i.e 50us / 59.52ns = 840 NOP'should
Time for 840 NOP's at Min time 59.52ns = 840 * 59.52ns = 50us
Time for 840 NOP's at nom time 62.5ns = 840 * 62.5ns = 52.5us
Time for 840 NOP's at max time 65.79ns = 840 * 65.79ns = 55.263us
2. As STM8S003F3, Accuracy of Internal oscillator = +-5% over all temperature ranges.
3. WS2811 specifies:
a) T0H = 0.5μs ±150ns
b) T1H = 1.2μs ±150ns
c) T0L = 2.0μs ±150ns
d) T1L = 1.3μs ±150ns
e) RES = Above 50μs
4. With 16Mhz crystal, time for NOP is 1/16Mhz = 0.0625us
With on left end of accuracy -5%, time for NOP is 1/(16*.95) = 65.79ns
With on right end of accuracy +5%, time for NOP is 1/(16*1.05) = 59.52ns
5. Are below calculations for NOP's are ok? I think internal oscillator can also be used.
6. a) T0H = 0.5μs ±150ns
variation allowed around 0.5us is +-150ns i.e = 0.35us to 0.65us
NOP's in T0H = 0.5μs / 0.0625us = 8
Taking 8 NOP will generate = 0.5us
variation with +5% accuracy = 8 * 59.52ns = 0.476us
variation with -5% accuracy = 8 * 65.79ns = 0.526us
So well within specs here
b) T1H = 1.2μs ±150ns
variation allowed around 1.2us is +-150ns i.e = 1.05us to 1.35us
NOP's in T1H = 1.2μs / 0.0625us = 19.2
Taking 19 NOP will generate = 1.1875us
variation with +5% accuracy = 19 * 59.52ns = 1.131us
variation with -5% accuracy = 19 * 65.79ns = 1.25us
So well within specs here
c) T0L = 2.0μs ±150ns
variation allowed around 2.0us is +-150ns i.e = 1.85us to 2.15us
NOP's in T0L = 2.0μs / 0.0625us = 32
Taking 32 NOP will generate = 2.0μs
variation with +5% accuracy = 32 * 59.52ns = 1.905us
variation with -5% accuracy = 32 * 65.79ns = 2.105us
So well within specs here
d) T1L = 1.3μs ±150ns
variation allowed around 1.3us is +-150ns i.e = 1.15us to 1.45us
NOP's in T1L = 1.3μs / 0.0625us = 20.8
Taking 21 NOP will generate = 1.3125μs
variation with +5% accuracy = 21 * 59.52ns = 1.25us
variation with -5% accuracy = 21 * 65.79ns = 1.382us
So well within specs here
e) RES = Above 50μs
So number of NOP's should be so that,
at minimum clock time it should have at-least 50us
i.e 50us / 59.52ns = 840 NOP'should
Time for 840 NOP's at Min time 59.52ns = 840 * 59.52ns = 50us
Time for 840 NOP's at nom time 62.5ns = 840 * 62.5ns = 52.5us
Time for 840 NOP's at max time 65.79ns = 840 * 65.79ns = 55.263us