We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I've been learning about uart recently and i was wondering how to use it on the 80C52. Assuming i have space, im going to put a gps and maybe 3g module in there somewhere. For the gps i wanted to use navit of course, but does navit have like a uart input? or will it just... work? I don't really know what im tring to ask
"I've been learning about uart recently and i was wondering how to use it on the 80C52."
So what have you been learning about the UART that didn't include how to use it?!
Go to http://www.8052.com/faqs and there's a whole section on 8052 Serial Comms, including this tutorial: www.8052.com/.../120308
"For the gps i wanted to use navit of course"
Why "of course"?
What is "navit"?
"does navit have like a uart input?"
How can you be so sure that "navit" is the thing to use if you don't even know that it has the necessary interface for your requirement?!
"or will it just... work?"
Nothing "just works" - everything requires you to make it work!
Here is the procedure to follow: www.8052.com/.../160143
yeah, i knew about the bluetooth gps and usb 3G, but i don't really like carrying extra bricks around if i don't have to. in short, i want to find room for the speakers and on a pcb itself. I'll make it fit if it kills me.
I don't mind surface mount soldering, so stealing 3.0-4-2 volts from a battery can power the module i suppose. I thought there would be a 3.3 and 5.0 volt i could steal from the power regulator/controller but i guess not
thanks for the details Andy, maybe i should have just looked up the specs but i don't know if the team had changed anything.
does anyone know the baud rate? Is it 115200, data - 8 bit, no even parity, stop - 1 bit?
You're throwing around random details as if everyone is already thoroughly familiar with you and your project - but we're not!
"i want to find room for the speakers"
What speakers?
"a battery can power the module i suppose."
What module?
"maybe i should have just looked up the specs"
Yes, definitely.
" i don't know if the team had changed anything"
What team?
And if you don't know what the rest of your team's up to, how is anyone else supposed to know?!
"does anyone know the baud rate?"
Baud rate of what??
here is some code
#ifndef __LCD_H__ #define __LCD_H__ void lcd_init(void); void delay(); void control_word(unsigned char ch); void data_word(unsigned char ch); void wrt_value(unsigned char x); void cursorxy(unsigned char x, unsigned char y); void disp_str(unsigned char msg[]); void wrt_string(unsigned char *string); void wrt_long(unsigned long a); void wrt_char(unsigned char a); void wrt_int(unsigned int a); void wrt_dec_char(unsigned char x); void wrt_dec_long(unsigned long a); void wrt_dec_int(unsigned int a); void wrt_2dec_place(unsigned char a); void wrt_float(float a); #endif #include <reg51.h> #define LCD P2 // lcd connected to this port void delay() { unsigned char i; for (i=0; i<255 ;i++); } void control_word(unsigned char ch) { unsigned char copy; copy = ch; //save a copy of it ch = ch >> 4; //get the higher nibble ch = ch & 0x0f; // -- do -- ch = ch | 0x20; // add E(bit 6) & RS (bit 5) LCD = ch; //out to lcd data port HIGHER nibble with E=1, RS=0 ch = ch & 0x0f; // make E=0, RS=0 with higher nibble LCD = ch; //out to lcd data port higher nibble with E=0, RS=0 ch = copy; //get original byte ch = ch & 0x0f; //to get lower nibble ch = ch | 0x20; // E=1, RS=0 LCD = ch; //out to lcd data port LOWER nibble with E=1, RS=0 ch = ch & 0x0f; // make E=0, RS=0 LCD = ch; //out to lcd data port lower nibble with E=0, RS=0 delay(); // give some delay here // } void data_word(unsigned char ch) { unsigned char copy; copy = ch; //save a copy of it ch = ch >> 4; //get the higher nibble ch = ch & 0x0f; // -- do -- ch = ch | 0x30; // add E(bit 6) & RS (bit 5) LCD = ch; //out to lcd data port HIGHER nibble with E=1, RS=1 ch = ch & 0x1f; // make E=0, RS=1 with higher nibble LCD = ch; //out to lcd data port higher nibble with E=0, RS=1 ch = copy; //get original byte ch = ch & 0x0f; //to get lower nibble ch = ch | 0x30; // E=1, RS=1 LCD = ch; //out to lcd data port LOWER nibble with E=1, RS=1 ch = ch & 0x1f; // make E=0, RS=1 LCD = ch; //out to lcd data port lower nibble with E=0, RS=1 delay(); // give some delay here } void lcd_init(void) { control_word(0x28);// 4bit, 2lines, 5x7 control_word(0x28);// again control_word(0x0E);// disp On, cursor On, no blink control_word(0x01);// clear LCD control_word(0x06);// CUR_RIGHT control_word(0x80);// line 1 cur. position 0 } void disp_str(unsigned char msg[]) { unsigned char i; while(msg != '\0') { data_word(msg[i++]); } } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bringing Cursor to (X,Y) location of LCD X -> 1,2 Y -> 1,16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ void cursorxy(unsigned char x, unsigned char y) { if((x<1||x>2)&&(y<1||y>16)) { x=1; y=1; } if(x == 1) control_word(0x7F+y); else control_word(0xBF+y); } void wrt_value(unsigned char x) { unsigned char temp; temp = x/0x10; if(temp>9) return; else data_word(temp+0x30); temp = x%0x10; if(temp>9) return; else data_word(temp+0x30); } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Writing string to LCD ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ void wrt_string(unsigned char *string) { delay(); while(*string) data_word(*string++); } //----------------------------------------------- void wrt_long(unsigned long a) { unsigned char i; unsigned char b,c[8]={48,48,48,48,48,48,48,48}; for(i = 7;a > 0;i--) { b = a % 16; if(b <= 9) b = b + 48; else b = b + 55; a = a / 16; c = b; } for(i =0; i<=7;i++) data_word(c); } //----------------------------------------------- void wrt_int(unsigned int a) { unsigned char i; unsigned char b,c[4]={48,48,48,48}; for(i = 3;a > 0;i--) { b = a % 16; if(b <= 9) b = b + 48; else b = b + 55; a = a / 16; c = b; } for(i =0; i<=3;i++) data_word(c); } //----------------------------------------------- void wrt_char(unsigned char x) { unsigned char temp; temp = x/0x10; if(temp>9) data_word(temp+55); else data_word(temp+48); temp = x%0x10; if(temp>9) data_word(temp+55); else data_word(temp+48); } //------------------------------------ void wrt_dec_char(unsigned char a) { unsigned char i; unsigned char b,c[3]={48,48,48}; for(i = 2;a > 0;i--) { b = a % 10; b = b + 48; a = a / 10; c = b; } for(i =0; i<=2;i++) data_word(c); } //----------------------------------------------- void wrt_dec_long(unsigned long a) { unsigned char i; unsigned char b,c[10]={48,48,48,48,48,48,48,48,48,48}; for(i = 9;a > 0;i--) { b = a % 10; b = b + 48; a = a / 10; c = b; } for(i =0; i<=9;i++) data_word(c); } //----------------------------------------------- void wrt_dec_int(unsigned int a) { unsigned char i; unsigned char b,c[5]={48,48,48,48,48}; for(i = 4;a > 0;i--) { b = a % 10; b = b + 48; a = a / 10; c = b; } for(i =0; i<=4;i++) data_word(c); } //------------------------------------ void wrt_2dec_place(unsigned char a) /* function to write the fractional part after decimal upto two decimal places INPUT : the decimal part as unsigned char */ { unsigned char i; unsigned char b,c[2]={48,48}; for(i = 1;a > 0;i--) { b = a % 10; b = b + 48; a = a / 10; c = b; } for(i =0; i<=1;i++) data_word(c); } //------------------------------------ void wrt_float(float a) /* function to write the floating point number upto two decimal places INPUT : floating point number OUTPUT : xxxxx.yy on lcd at current cursor position */ { unsigned int i; unsigned char j; i = (unsigned int)a; wrt_dec_int(i); wrt_string("."); j = (unsigned char)((a - i) * 100); wrt_2dec_place(j); } //-----------------------------------------------
indeed there is - but does it have anything at all to do with this thread??