Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Status
Not open for further replies.

Tymoty

New Member
Hi, I try convert voltage from MMA7260Q and show on lcd but it doesn't work. this is my code

g1=0;
g2=0;
_asm NOP _endasm
_asm NOP _endasm

_asm NOP _endasm
_asm NOP _endasm

PutMessage((rom char*)"\x16\x0\x8 X:");
PutMessage(osaX);
PutMessage((rom char*)"\x16\x0\x24 Y:");
PutMessage(osaY);
}

and before this in main.c

and on senzor is voltage about 1,65V(axes x,y) and when i connect mcu voltage is cca 0,2V. i don't know why

birdman0_o

Active Member

Multiplying by 256 gives you what?

Pommie

Well-Known Member
Assuming you are using my GLCD code, you have a few problems here. The PutMessage routine only works with strings that are stored in ROM, your 0azX is not a string and is not stored in ROM. The way to fix this is to write a new function that will print an integer.

A simple version would be,
Code:
void PutInt(unsigned int num){
PutChar((num/1000)%10+0x30);
PutChar((num/100)%10+0x30);
PutChar((num/10)%10+0x30);
PutChar((num)%10+0x30);
}

I have not checked your ADC code but it looks like you don't leave enough acquisition time.

Mike.

csaba911

Member
xxxxxx10 in adresh = 2 = 2*256 = 512
so 10 bit adc result from 1010110101 = 693

Csaba

Tymoty

New Member
Thank you pommie, your code running great. I had mystake in configuration of trisa (i use ra0 and ra1 and i had ra6 and ra7).

and pommie I hope that I can use your glcd routine. I use this for my school project and of course I write you like author. but I need some info about you, I can't write to my project - routine from some forum from pommie
thank you

Pommie

Well-Known Member
Feel free to use my code, it is in the public domain and so that should make it acceptable. If you have any problems with citation then I can give you additional information.

Mike.

Status
Not open for further replies.

Replies
21
Views
3K
Replies
2
Views
2K
Replies
0
Views
2K
Replies
2
Views
1K
Replies
0
Views
2K