![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #16 |
|
The way you would get the data into a string would be something along the line of, Code: char Buff[11];
void getString(){
char i;
while(getChar()!=0x24); //wait for start of packet
for(i=0;i<10;i++){ //get 10 characters
Buff[i]=getChar(); //and put them in the buffer
}
}
Mike. Last edited by Pommie; 20th July 2009 at 04:20 PM. Reason: Had Buff[i]==getChar(); | |
| |
| | #17 | |
| Quote:
Lovely... will try tonight. Suppose char i; should be int i; //??? While I am at it, another silly question: I connect the pin on the compass module marked RXD with the Zilog pin TXD, and vica-versa? | ||
| |
| | #18 | |
| Quote:
Yes, cross connect RX and TX but you must remove the RS232 converter on the target board. You either need two level converters or none. Edit, hadn't realised there is a second UART without a Max232 - that should work fine. Mike. Last edited by Pommie; 21st July 2009 at 08:17 AM. | ||
| |
| | #19 |
|
I have conneced it all up, although when I read rx data, I only get, 00, as well as a framing error and overrun error, after a couple of reads. Also, that was after a lot of coaxing to get it to actually read uart1 instead of the default uart0... It seems as though there is always one char available at startup (after entering main() ), even with the module unpowered (value also 00). Then, when I power the module, more become available (all 00, as mentioned). I tried in interrupt mode and polling mode. Things arent as easy as I thought they might be :blush I might start debugging by putting the compass module into an oscilloscope - I should make sure that is working first... I suppose that will work? Also, I am using wire (around 3") between the dev board and the module - is that going to ruin the signal? | |
| |
| | #20 |
|
If you are getting framing and overrun errors then I would check your baud rate. To check the compass is doing as you expect you can connect it to a PC via a MAX232 and use hyperterminal to view the output. Edit, I just looked at the data sheet for your compass and it doesn't state the baud rate or if the TTL levels are inverted. If you have a scope then you should be able to work them out. Mike. Last edited by Pommie; 22nd July 2009 at 06:53 AM. | |
| |
| | #21 |
|
contacted manufacturer. default baud9600, one stop bit, no parity... which is what i was using. Will try and look with scope, but might take a while to get one to use...
| |
| |
| | #22 | |
| Quote:
If you connect a MAX232 to the Compass output you will be able to use a PC to communicate with the Compass.
__________________ Eric " Good enough is Perfect " I will NOT answer PM's requesting technical help, please use the Forum PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | #23 | |
| Quote:
Try putting a delay in your startup code where you set the pin directions, then the delay (this lets the pin voltages settle etc), THEN initialise the UART. I'm not sure why you get the same problem "after a couple of reads" but I would definitely look at the problem happening at startup first, that might lead to solving the second problem. | ||
| |
| | #24 |
|
It's alive! ![]() My first microcontroller interface!![]() Thanks guys. I ended up relaying everything from compass on UART1 to hyperterminal via UART0 and its max232. Wasnt getting any readings, and checked connections again... I think they have mis-labelled the rx/tx pins on the compass module, because it works now having swapped the lines - so now they are not crossed-over (rx-rx and tx-tx). Then again, I have been known to get things wrong when it comes to connecting things on the opposite side of a board to the drawing, when a 50/50 chance will get it wrong... Some output: Next Reading $H,109*3A Next Reading $H,110*32 Next Reading $H,110*32 Next Reading $H,106*35 (Mike, my getChar() routine sent the received char to the hyperterminal, so thats why the $ appears in above readings) The 109, 110, and 106 are heading degrees Wow, this site and you guys are awesome. Standby for more problems from me. Cheers, Rob | |
| |
| | #25 |
|
i have a problem whith the boudrate when i am using the soft uart of pic mcu plz i need a help | |
| |
| | #26 |
|
engiah, I am pretty new myself. I havent used a software uart. Maybe someone else here can help you out. Cheers, Rob | |
| |
| | #27 |
|
I have a couple of projects on my page that use a soft uart on PIC. This one uses PIC 16F876 in assembler and sends 31250 baud for MIDI; (it says C but the uart "send byte" code is in assembler) MIDI-Bash2 MIDI drum controller This page has 4 projects in C. Project3 sends and receives software uart; Connect JuneBug to serial port and Sharp GP2 sensor | |
| |
| | #28 |
|
THX 4 u rob and THX 4 u MR RB | |
| |
| | #29 |
|
sir robmitch, can u post ur code on receiving data from the compass?, im also dealing with the same problem about the electronic compass. can i become ur apprentice?!! | |
| |
| | #30 |
|
skidd10, are you using the same compass module? | |
| |
|
| Tags |
| problems, receive, uart |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| PIC 16F877 UART receive | yueying_53 | Micro Controllers | 0 | 19th October 2008 08:52 AM |
| How can I Transmit/ Receive BCD | noman_dk | Electronic Projects Design/Ideas/Reviews | 3 | 23rd February 2008 05:59 PM |
| Receive data via SPI | Sam Jelfs | Micro Controllers | 2 | 11th April 2007 06:33 AM |
| receive data from other pic | janetsmith2000@yahoo.com | Micro Controllers | 1 | 24th March 2004 07:28 PM |
| receive 0 data from UART..... | wingbar | General Electronics Chat | 5 | 15th March 2004 07:11 PM |