![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
hello everyone.
i have written a very simple program for PIC16f628, which sends the word "hello" over the TX UART pin, to the RX pin of a DLP(device which recieves rs232 and sends it out via usb to a different device). The DLP is connected to my pc via USB. I have created a virtual comport COM6 for the DLP, so that the PIC can communicate with pc in a serial fashion, but through the interface of a USB connection instead of an old fashioned 9pin serial way. hope this makes sense. anyway, set up the PIC to transmit the data as soon as it starts up once, then to transmit it whenever rb4 is set high by pressing a button etc. i have made a connection to the DLP that the PIC is connected to via hyperterminal. i am using baudrate of 9600, 1stop bit, no parity. i am not seeing my message come up onto the screen in hyperterminal. i have looked over my code a thousand times and i cant find the problem. could someone please look at my code, to confirm to me if the PIC is actually properly outputting the data through its UART TX pin. this way i can find out if the problem is with my programming of the PIC or with the DLP. i am using hyperterminal private edition, on windows vista, because for some reason they decided not to include hyperterminal. please help because iv exhaused myself trying to fix this by i cant find the problem and its starting to make me depressed. i have attatched the code thank you
__________________
life\'s a bitch then u marry one. |
|
|
|
|
|
|
(permalink) |
|
The 16F628 data sheet states that RX and TX should be set to input in order to use the UART. Also, are you using a max232, it may be that the UART to USB chip takes TTL level data or you may need a level converter.
One other thing, your goto message will cause a crash. Mike. |
|
|
|
|
|
|
(permalink) |
|
hi,
Runs OK, on OS Pic sim, prints 'hello' on UART window, then stops. As Mike says, check the level shifters, also make sure you are using pin #8 of the PIC. Mikes...One other thing, your goto message will cause a crash. make it a Call and it controls OK with B4.
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 13th December 2007 at 01:42 PM. |
|
|
|
|
|
|
(permalink) |
|
hey thanks for your reply. but, where does it say that the rx, AND tx pin should be input?? i couldnt see that? i thought that tx must be output and rx must be input.
the pics uart uses NRZ so that is not TTL. i have attatched the datasheet for the DLP. i am using it in rs232 serial mode. my friend said that pins such as RTS ,CTS, DTR, DSR etc do not have to be used (as seen on page 18 of datasheet in table), he said only the tx and rx pins, pin 39 and 40 must be used. if so why have the other pins, surely they must be there for a reason?
__________________
life\'s a bitch then u marry one. |
|
|
|
|
|
|
(permalink) |
|
here is the datasheet for the DLP i am using.
__________________
life\'s a bitch then u marry one. |
|
|
|
|
|
|
(permalink) |
|
Before you start pulling your hair, check your cable.
If you do not have oscilloscope, as a simple test, you can write a little program to periodically send a character to UART and check with AC meter which line is toggling.
__________________
www.dipmicro.com |
|
|
|
|
|
|
(permalink) |
|
There is a lot of places to make a mistake with this type of connection and PIC is just one of them. Make sure your hyperterm and USB to serial are set up correctly. In order to do this short tx and rx pins of the USB to serial chip on the TTL side, open the hyperterm and type something on the keyboard. If everything is set up correctly you should get characters that you type echoed back on the screen. If you're not getting echo check flow control of your virtual serial (should be set to none) and VCCIOx pins on the chip (they should receive power). When you get this part done you may start troubleshooting the PIC.
|
|
|
|
|
|
|
(permalink) | |
|
On page 78, step 1 of the description for how to transmit is,
Quote:
Mike. |
||
|
|
|
|
|
(permalink) |
|
your code work properly here (with goto message change to call message), but i doubt of the reliability of ANY internal OSC. See here, 1 out 5 don't work with internal and just send garbage while i don't see any problem with a real 4Mhz crystal.
|
|
|
|
|
|
|
(permalink) |
|
I have never had a problem sending serial data with the internal oscillator. My current project has serial at 115k and uses the internal oscillator without problem. I would guess that in order to get the last bit wrong your timing would have to be out by ½ a bit or 5%. The internal oscillator is accurate to 1%. Are you maybe thinking of AVRs where the error can be 5%?
Mike. |
|
|
|
|
|
|
(permalink) |
|
I too have not experienced problems with serial communications when using INTOSC on many many projects.
|
|
|
|
|
|
|
(permalink) |
|
I may agree with some newer PIC wich have internal calibration... and 1% marked on... but this poor ol' 628? maybe 628A is better... look the regular 16F628 datasheet
http://ww1.microchip.com/downloads/e...Doc/40300C.pdf pdf page 138, parameter 4 And bear in mind it's an RC osc.. so it WILL shift at least with temperature variations. Not fan of it for reliable serial comm... Last edited by mister_e; 14th December 2007 at 01:27 AM. |
|
|
|
|
|
|
(permalink) |
|
Mister E,
You are correct, the error with the non A version is substantially higher and could cause serial communication problems - I have only used the later version and, therefore, did not appreciate this fact. However, this is not the OPs problem as if it was he would be getting garbled data rather than no data. I think his problem is hardware - probably no level shifter. Mike. |
|
|
|
|
|
|
(permalink) |
|
mister_e,
I was referring to experiences with the newer devices with INTOSC 1% tolerance too. If your recommendation is based on your experiences with "old" devices then your experience and recommendation are both a bit out-of-date. |
|
|
|
|
|
|
(permalink) |
|
Yup, i'm not totally close to the idea, i should try it one day. But now, i still use the old 'thinking' even with newer PIC... i'm afraid... there's people like that
|
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Quik PIC Programming kit | Krumlink | General Electronics Chat | 5 | 27th January 2008 11:27 PM |
| Problems switchin relay with PIC | Andy1845c | General Electronics Chat | 5 | 17th November 2007 06:13 PM |
| High ADC sampling rate PIC, 18F needed? | bananasiong | Micro Controllers | 24 | 28th October 2007 12:13 PM |
| PIC16F88, PIC simulator lcd trouble | superbrew | Micro Controllers | 11 | 17th October 2007 02:17 AM |
| Programming PIC to generate square wave | elec123 | Micro Controllers | 11 | 13th October 2007 01:15 PM |