DALI commands reading

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

DALI commands reading

2,479 次查看
Chish
Contributor II

Hello! Posting again

I'm working on DALI to monitor the hours of LEDs connected to DALI slave. I'm using LPC1114/302 MCU. 
According to Standard DALI protocol I can only send 8 bits to DALI Master. I'm trying to separate the logic by using Modulus operator and send it to the DALI master but it doesn't work. I've attached the in which i applied different logics to separate the digits and send it over. 

The stunde is hour, whose value is 329 and I need to split them into 3 digits \

MSB 3,

MIDB 2,

LSB 9

Chish_0-1636023714655.png

 

标记 (1)
0 项奖励
回复
3 回复数

2,472 次查看
Chish
Contributor II

Actually, I've just started programming in C and since it's related to DALI and I'm working on NXP MCU that's why

 

0 项奖励
回复

2,465 次查看
converse
Senior Contributor V

Assuming that you are trying to extract the decimal digits, here is a bit of code that may help you:

int val = 329 ; // the value to  convert

int result[3] ; // an array containing each decimal digit.
// the least significant digit is in result[0]
int digits = 0 ;
while(val > 0){
result[digits++] = val % 10 ;
val = val / 10 ;
}

This will convert a number containing up to 3 decimal digits and place the result into the result[] array (in reverse order). To simplify the code, there is no error checking, so if the value is larger than 999, the result array will overflow and corruption will occur!!! You can modify this code to suit your particular circumstances. 

0 项奖励
回复

2,473 次查看
carstengroen
Senior Contributor II

Not to be rude, but what has this to do with "NXP microprocessors" ?

It is a simple beginner C question (in fact, a general programming beginner question).

0 项奖励
回复