Hi guys,
Hi have understand the request and replies for ADC comuinication.
Now I replies with this data:
CANTXDLR = myvarbyt;
CANTXDSR0 =MapTPS1/256/10;
CANTXDSR1 =MapTPS1/10-256*CANTXDSR0;
CANTXDSR2 =MapTPS2/256/10;
CANTXDSR3 =MapTPS2/10-256*CANTXDSR2;
CANTXDSR4 =MapPED1/256/10;
CANTXDSR5 =MapPED1/10-256*CANTXDSR4;
CANTXDSR6 =MapPED2/256/10;
CANTXDSR7 =MapPED2/10-256*CANTXDSR6;
My variable is +- 0-10000. But this make the error.
I suppose wich I have DSR0 and DSR1 max is 255 for total 65536. But if DSR0 is > 12 I don't see the correct value in ms gauge.
What is the correct way?
thanks regards
CAN and ADC
Moderators: jsmcortina, muythaibxr
-
- Site Admin
- Posts: 39617
- Joined: Mon May 03, 2004 1:34 am
- Location: Birmingham, UK
- Contact:
Re: CAN and ADC
Try:
*(unsigned int*)&CANTXDSR0 = MapTPS1 / 10;
*(unsigned int*)&CANTXDSR2 = MapTPS2 / 10;
*(unsigned int*)&CANTXDSR4 = MapPED1 / 10;
*(unsigned int*)&CANTXDSR6 = MapPED2 / 10;
OR:
CANTXDSR0 = (MapTPS1 / 10) >> 8;
CANTXDSR1 = (MapTPS1 / 10) & 0xff;
etc.
James
*(unsigned int*)&CANTXDSR0 = MapTPS1 / 10;
*(unsigned int*)&CANTXDSR2 = MapTPS2 / 10;
*(unsigned int*)&CANTXDSR4 = MapPED1 / 10;
*(unsigned int*)&CANTXDSR6 = MapPED2 / 10;
OR:
CANTXDSR0 = (MapTPS1 / 10) >> 8;
CANTXDSR1 = (MapTPS1 / 10) & 0xff;
etc.
James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
-
- Super MS/Extra'er
- Posts: 855
- Joined: Sun Oct 10, 2010 6:33 am
Re: CAN and ADC
Thanks James... work .
I use the second solution.
Very thanks
Regard
Cristian
I use the second solution.
Very thanks
Regard
Cristian