Reply by old_cow_yellow July 27, 20072007-07-27
--- In m..., sai ramesh raghuraman
wrote:
>
> Hi friends,
>
> While thanking Shoaib and Bill for replies, I would like to share
with you a file(configuring USART.pdf) which I came across in the net.
I have posted it in the files section of this group. There is a step
by step explanation on how to set the modulator bits of USART.
>
> regards

> ---------------------------------
> Choose the right car based on your needs. Check out Yahoo! Autos
new Car Finder tool.
>
>
>

Thanks for posting slaa049.pdf.

If I use a 455kHz clock and try to get 57.6kb/s, the division factor
is 455/57.6=7.8993. According to the method described in slaa049.pdf,
UMCTL should be set to 0xFF. But this will produce max. 12.7% error.
If I set UMCTL to 0xDF or 0xEF, the max. error is only 6.3%

Beginning Microcontrollers with the MSP430

Reply by sai ramesh raghuraman July 27, 20072007-07-27
Hi friends,

While thanking Shoaib and Bill for replies, I would like to share with you a file(configuring USART.pdf) which I came across in the net. I have posted it in the files section of this group. There is a step by step explanation on how to set the modulator bits of USART.

regards

---------------------------------
Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
Reply by old_cow_yellow July 26, 20072007-07-26
I think you might do something like this:

void convert(unsigned int gross, unsigned int tare, char dig[6])
{
unsigned int net;
if (gross >= tare)
{
net = gross - tare;
dig[5] = net % 10; net /= 10;
dig[4] = net % 10; net /= 10;
dig[3] = net % 10; net /= 10;
dig[2] = net % 10; net /= 10;
dig[1] = net % 10;
dig[0] = 0;
}
else
dig[5] = dig[4] = dig[3] =dig[2] = dig[1] = dig[0] = 8;
}

--- In m..., alex ander wrote:
>
> Hi Richard,
> Thanks for throwing some light. You probably
figured out that i am asked to
> do this programming job for the 1st time....Ok
the idea was to divide the hex
> by 0x1000 and store it as an integer to separate
the 1st digit. i.e
> 5ACD /0X1000 = 0X0005....and then i was trying
to multiply this value
> by 4096 decimal to get the equivalent 10,000
digit of the hex value.....i.e
> 5x4096 = 20480 and then similarly go on
extracting the remaining digits and
> add them all up to get an equivalent number i.e
23245....Since this logic seem
> to work good on calculator (with hex and decimal
conversion) i took a chance
> implementing it. The portion up to digit
separation seem to work ok but
> in the next instruction , the dec_sum variable
goes nuts...the watch window
> starts displaying 0x000003cd e-41.......wasn;t
sure of this portion ......I hope
> you get the logic i am trying to implement and
appreciate your patience
> and help on the same....
> This is for a fancy
weighing scale and i wasn;t aware of
> terminology & there are no specs given . I
corrected the spelling of tare.
> Also took care of the
tare value and added a new variable
> that stores 16 bit value of tare before
subtraction.....Thanks for the help here.
> I would also like
to know more about the coding style if you
> could tell me....Thanks in advance.....
>
> "Richard (UK)." wrote:
> It's early in the morning here and I am probably very dumb
... but I'm not
> sure what you are trying to do here.
>
> What is the "parsing" all about? Am I missing something obvious here?
>
> Are you simply talking a 16-bit value and wanting to display it as a
decimal
> value using five 4-bit BCD/hex displays?
> If so, why do you extract a series of 4-bit fields from the original
16-bit
> value ... and then apparently recreate the original 16-bit value
from them
> again?
>
> Also, if this is a weighing machine program, the spelling is "tare"
and not
> "tear".
> Note that you can't do the 16-bit tare subtraction in two 8-bit parts
> without allowing for "borrow".
>
> Do you really need "longs"?
>
> I could also make a few points about coding style ... but I'm sure
someone
> else will be able to help out there ...
>
> ----- Original Message -----
> From: europus
> To: m...
> Sent: Thursday, July 26, 2007 1:47 AM
> Subject: [msp430] Trying to display 7 segment BCD on LCD from ADC.
>
> Hi All,
> I am trying to display BCD numbers on LCD from 16 bit ADC.
> The code posted below is suppose to 1st parse the 16 bit
> number digit wise and then convert it to corresponding decimal
> value which i will display on LCD after some processing. The
> problem is i am not getting the output as desired ...Many
> variables in this function give out weird values...Can anyone
> one tell me why?low_byte and high_byte are global varibles and
> are high byte and low byte from 16 bit ADC.The display driver chips
> used are ICM7211......thanks in advance,....
>
> void display()
> {
> unsigned int msb,lsb;
> unsigned int disp_dig1,disp_dig2,disp_dig3,
> disp_dig4,disp_dig5,disp_dig6;
> unsigned int digit1,digit2,digit3,digit4,
> dec_dig4,dec_dig5,dec_dig6;
> unsigned int full_val,dec_dig2,dec_dig3;
> unsigned long dec_dig1,dec_sum;
> msb=high_byte-tear_high; //subtract tear value from i/p
> sample//
> lsb=low_byte-tear_low; //subtract tear value from i/p
> sample//
> full_val=msb*256; //left shift msb by 8 bits//
> full_val=full_val | lsb; //create a 16 bit value//
> digit1=full_val/0X1000; //Parse the 1st digit//
> digit2=full_val-(digit1*0X1000);//Parse the 2nd digit//
> digit2=digit2/0X100; //Parse the 2nd digit//
> digit3=full_val-(digit1*0X1000+digit2*0X100); //Parse the
> 3rd digit//
> digit3=digit3/0X10; //Parse the 3rd digit//
> digit4=full_val-(digit1*0X1000+digit2*0X100+digit3*0X10);
> //Parse 4th digit//
> dec_dig1=digit1*0X1000;
> dec_dig2=digit2*0X100;
> dec_dig3=digit3*0X10;
> dec_dig4=digit4;
> dec_sum_dig1 + dec_dig2 + dec_dig3 + dec_dig4;
> disp_dig1_sum/10000;
> disp_dig2_sum-(disp_dig1*10000);
> disp_dig2=disp_dig2/1000;
> disp_dig3_sum-(disp_dig1*10000+disp_dig2*1000);
> disp_dig3=disp_dig3/100;
> disp_dig4_sum-(disp_dig1*10000+disp_dig2*1000
> +disp_dig3*100);
> disp_dig4=disp_dig4/10;
> disp_dig5_sum-(disp_dig1*10000+disp_dig2*1000
> +disp_dig3*100+disp_dig4*10);
>
> }
>
>
>
>
> ---------------------------------
> Yahoo! oneSearch: Finally, mobile search that gives answers, not
web links.
>
>
>
Reply by alex ander July 26, 20072007-07-26
Hi Richard,
Thanks for throwing some light. You probably figured out that i am asked to
do this programming job for the 1st time....Ok the idea was to divide the hex
by 0x1000 and store it as an integer to separate the 1st digit. i.e
5ACD /0X1000 = 0X0005....and then i was trying to multiply this value
by 4096 decimal to get the equivalent 10,000 digit of the hex value.....i.e
5x4096 = 20480 and then similarly go on extracting the remaining digits and
add them all up to get an equivalent number i.e 23245....Since this logic seem
to work good on calculator (with hex and decimal conversion) i took a chance
implementing it. The portion up to digit separation seem to work ok but
in the next instruction , the dec_sum variable goes nuts...the watch window
starts displaying 0x000003cd e-41.......wasn;t sure of this portion ......I hope
you get the logic i am trying to implement and appreciate your patience
and help on the same....
This is for a fancy weighing scale and i wasn;t aware of
terminology & there are no specs given . I corrected the spelling of tare.
Also took care of the tare value and added a new variable
that stores 16 bit value of tare before subtraction.....Thanks for the help here.
I would also like to know more about the coding style if you
could tell me....Thanks in advance.....

"Richard (UK)." wrote:
It's early in the morning here and I am probably very dumb ... but I'm not
sure what you are trying to do here.

What is the "parsing" all about? Am I missing something obvious here?

Are you simply talking a 16-bit value and wanting to display it as a decimal
value using five 4-bit BCD/hex displays?
If so, why do you extract a series of 4-bit fields from the original 16-bit
value ... and then apparently recreate the original 16-bit value from them
again?

Also, if this is a weighing machine program, the spelling is "tare" and not
"tear".
Note that you can't do the 16-bit tare subtraction in two 8-bit parts
without allowing for "borrow".

Do you really need "longs"?

I could also make a few points about coding style ... but I'm sure someone
else will be able to help out there ...

----- Original Message -----
From: europus
To: m...
Sent: Thursday, July 26, 2007 1:47 AM
Subject: [msp430] Trying to display 7 segment BCD on LCD from ADC.

Hi All,
I am trying to display BCD numbers on LCD from 16 bit ADC.
The code posted below is suppose to 1st parse the 16 bit
number digit wise and then convert it to corresponding decimal
value which i will display on LCD after some processing. The
problem is i am not getting the output as desired ...Many
variables in this function give out weird values...Can anyone
one tell me why?low_byte and high_byte are global varibles and
are high byte and low byte from 16 bit ADC.The display driver chips
used are ICM7211......thanks in advance,....

void display()
{
unsigned int msb,lsb;
unsigned int disp_dig1,disp_dig2,disp_dig3,
disp_dig4,disp_dig5,disp_dig6;
unsigned int digit1,digit2,digit3,digit4,
dec_dig4,dec_dig5,dec_dig6;
unsigned int full_val,dec_dig2,dec_dig3;
unsigned long dec_dig1,dec_sum;
msb=high_byte-tear_high; //subtract tear value from i/p
sample//
lsb=low_byte-tear_low; //subtract tear value from i/p
sample//
full_val=msb*256; //left shift msb by 8 bits//
full_val=full_val | lsb; //create a 16 bit value//
digit1=full_val/0X1000; //Parse the 1st digit//
digit2=full_val-(digit1*0X1000);//Parse the 2nd digit//
digit2=digit2/0X100; //Parse the 2nd digit//
digit3=full_val-(digit1*0X1000+digit2*0X100); //Parse the
3rd digit//
digit3=digit3/0X10; //Parse the 3rd digit//
digit4=full_val-(digit1*0X1000+digit2*0X100+digit3*0X10);
//Parse 4th digit//
dec_dig1=digit1*0X1000;
dec_dig2=digit2*0X100;
dec_dig3=digit3*0X10;
dec_dig4=digit4;
dec_sum_dig1 + dec_dig2 + dec_dig3 + dec_dig4;
disp_dig1_sum/10000;
disp_dig2_sum-(disp_dig1*10000);
disp_dig2=disp_dig2/1000;
disp_dig3_sum-(disp_dig1*10000+disp_dig2*1000);
disp_dig3=disp_dig3/100;
disp_dig4_sum-(disp_dig1*10000+disp_dig2*1000
+disp_dig3*100);
disp_dig4=disp_dig4/10;
disp_dig5_sum-(disp_dig1*10000+disp_dig2*1000
+disp_dig3*100+disp_dig4*10);

}

---------------------------------
Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.
Reply by "Richard (UK)." July 26, 20072007-07-26
It's early in the morning here and I am probably very dumb ... but I'm not
sure what you are trying to do here.

What is the "parsing" all about? Am I missing something obvious here?

Are you simply talking a 16-bit value and wanting to display it as a decimal
value using five 4-bit BCD/hex displays?
If so, why do you extract a series of 4-bit fields from the original 16-bit
value ... and then apparently recreate the original 16-bit value from them
again?

Also, if this is a weighing machine program, the spelling is "tare" and not
"tear".
Note that you can't do the 16-bit tare subtraction in two 8-bit parts
without allowing for "borrow".

Do you really need "longs"?

I could also make a few points about coding style ... but I'm sure someone
else will be able to help out there ...
----- Original Message -----
From: europus
To: m...
Sent: Thursday, July 26, 2007 1:47 AM
Subject: [msp430] Trying to display 7 segment BCD on LCD from ADC.
Hi All,
I am trying to display BCD numbers on LCD from 16 bit ADC.
The code posted below is suppose to 1st parse the 16 bit
number digit wise and then convert it to corresponding decimal
value which i will display on LCD after some processing. The
problem is i am not getting the output as desired ...Many
variables in this function give out weird values...Can anyone
one tell me why?low_byte and high_byte are global varibles and
are high byte and low byte from 16 bit ADC.The display driver chips
used are ICM7211......thanks in advance,....

void display()
{
unsigned int msb,lsb;
unsigned int disp_dig1,disp_dig2,disp_dig3,
disp_dig4,disp_dig5,disp_dig6;
unsigned int digit1,digit2,digit3,digit4,
dec_dig4,dec_dig5,dec_dig6;
unsigned int full_val,dec_dig2,dec_dig3;
unsigned long dec_dig1,dec_sum;
msb=high_byte-tear_high; //subtract tear value from i/p
sample//
lsb=low_byte-tear_low; //subtract tear value from i/p
sample//
full_val=msb*256; //left shift msb by 8 bits//
full_val=full_val | lsb; //create a 16 bit value//
digit1=full_val/0X1000; //Parse the 1st digit//
digit2=full_val-(digit1*0X1000);//Parse the 2nd digit//
digit2=digit2/0X100; //Parse the 2nd digit//
digit3=full_val-(digit1*0X1000+digit2*0X100); //Parse the
3rd digit//
digit3=digit3/0X10; //Parse the 3rd digit//
digit4=full_val-(digit1*0X1000+digit2*0X100+digit3*0X10);
//Parse 4th digit//
dec_dig1=digit1*0X1000;
dec_dig2=digit2*0X100;
dec_dig3=digit3*0X10;
dec_dig4=digit4;
dec_sum_dig1 + dec_dig2 + dec_dig3 + dec_dig4;
disp_dig1_sum/10000;
disp_dig2_sum-(disp_dig1*10000);
disp_dig2=disp_dig2/1000;
disp_dig3_sum-(disp_dig1*10000+disp_dig2*1000);
disp_dig3=disp_dig3/100;
disp_dig4_sum-(disp_dig1*10000+disp_dig2*1000
+disp_dig3*100);
disp_dig4=disp_dig4/10;
disp_dig5_sum-(disp_dig1*10000+disp_dig2*1000
+disp_dig3*100+disp_dig4*10);

}
Reply by europus July 25, 20072007-07-25
Hi All,
I am trying to display BCD numbers on LCD from 16 bit ADC.
The code posted below is suppose to 1st parse the 16 bit
number digit wise and then convert it to corresponding decimal
value which i will display on LCD after some processing. The
problem is i am not getting the output as desired ...Many
variables in this function give out weird values...Can anyone
one tell me why?low_byte and high_byte are global varibles and
are high byte and low byte from 16 bit ADC.The display driver chips
used are ICM7211......thanks in advance,....

void display()
{
unsigned int msb,lsb;
unsigned int disp_dig1,disp_dig2,disp_dig3,
disp_dig4,disp_dig5,disp_dig6;
unsigned int digit1,digit2,digit3,digit4,
dec_dig4,dec_dig5,dec_dig6;
unsigned int full_val,dec_dig2,dec_dig3;
unsigned long dec_dig1,dec_sum;
msb=high_byte-tear_high; //subtract tear value from i/p
sample//
lsb=low_byte-tear_low; //subtract tear value from i/p
sample//
full_val=msb*256; //left shift msb by 8 bits//
full_val=full_val | lsb; //create a 16 bit value//
digit1=full_val/0X1000; //Parse the 1st digit//
digit2=full_val-(digit1*0X1000);//Parse the 2nd digit//
digit2=digit2/0X100; //Parse the 2nd digit//
digit3=full_val-(digit1*0X1000+digit2*0X100); //Parse the
3rd digit//
digit3=digit3/0X10; //Parse the 3rd digit//
digit4=full_val-(digit1*0X1000+digit2*0X100+digit3*0X10);
//Parse 4th digit//
dec_dig1=digit1*0X1000;
dec_dig2=digit2*0X100;
dec_dig3=digit3*0X10;
dec_dig4=digit4;
dec_sum_dig1 + dec_dig2 + dec_dig3 + dec_dig4;
disp_dig1_sum/10000;
disp_dig2_sum-(disp_dig1*10000);
disp_dig2=disp_dig2/1000;
disp_dig3_sum-(disp_dig1*10000+disp_dig2*1000);
disp_dig3=disp_dig3/100;
disp_dig4_sum-(disp_dig1*10000+disp_dig2*1000
+disp_dig3*100);
disp_dig4=disp_dig4/10;
disp_dig5_sum-(disp_dig1*10000+disp_dig2*1000
+disp_dig3*100+disp_dig4*10);

}