View previous topic :: View next topic |
Author |
Message |
stacey
Joined: 14 Jan 2011 Posts: 22 Location: MY
|
Need help on how to start the UART |
Posted: Wed Mar 16, 2011 7:16 pm |
|
|
I just bought my UART and want to test to make sure whether it is function or not before further development with Visual basic.
Currently using Window 7, PIC C compiler, PIC16F877A.
Any test program I can use?
I test some program on web but it doesnt work, I wonder is that the different pic using or different compiler cause the problem. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
Re: Need help on how to start the UART |
Posted: Wed Mar 16, 2011 7:32 pm |
|
|
stacey wrote: | I just bought my UART and want to test to make sure whether it is function or not before further development with Visual basic.
Currently using Window 7, PIC C compiler, PIC16F877A.
Any test program I can use?
I test some program on web but it doesnt work, I wonder is that the different pic using or different compiler cause the problem. |
You have stated too many things in a somewhat jumbled order to make sense... so if you could restate more clearly, that would help.
This forum is specifically for the CCS Info line of Compilers that generate code for Microchip PIC microcontrollers.
If you are having problems with compiling code for the PIC using CCS PIC-C, then you're in the right place and need to reiterate more specifically what's going on.. be sure to include:
The compiler version
The PIC Device
A small compilable example demonstrating your issue.
Anything else is not really appropriate for this forum.
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
stacey
Joined: 14 Jan 2011 Posts: 22 Location: MY
|
Re: Need help on how to start the UART |
Posted: Wed Mar 16, 2011 8:10 pm |
|
|
Thanks for your advice.
The compiler used is CCS IDE version 4.038.
The PIC used is 16F877A.
Since I am using Windows 7 that do not have hyperterminal in default, I use Hyperterminal Applet.
I found the following test program in the web and try it but I not sure my steps correct or not.
1. Connect 3 pins on UART, 1 to ground, 1 to tx pin of PIC, 1 to rx pin of PIC
2. Another side of UART connect to laptop
3. Download my hex file into the pic
4. Open the hyperterminal and set the corresponding baud rate.
5. I want to type character inside the hyperterminal to try but it fail, mean i keep press on the keyboard but then nothing show in hyperterminal. No input and no output too.
Is that anything wrong in the process?
The following is the test program
Code: |
#include <16F877A.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//=========================================
void main()
{
char c;
printf("Start \n\r");
while(1)
{
c = getc(); // Get a character from the PC
putc(c); // Send the same character to the PC
}
}
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9217 Location: Greensville,Ontario
|
|
Posted: Wed Mar 16, 2011 8:53 pm |
|
|
You need add a MAX232 or equal chip between the PIC and the PC hookups. This chip will interface the PIC and PC to the proper RS232 signal levels. This is shown in the CCS C compiler manual and several examples are on the web of how to hookup the hardware properly.
Also be sure to have the correct caps for the xtal circuit of the PIC, as well as a good, regulated 5 volt supply, properly bypassed to reduce noise.
If it doesn't work after that, I suggest you try a simple 'blinking LED' program to verify that you're actually downloading the PIC with the correct program. Again, there are examples that CCS supplies, both in print and in the 'folders' directory. |
|
|
stacey
Joined: 14 Jan 2011 Posts: 22 Location: MY
|
|
Posted: Wed Mar 16, 2011 9:10 pm |
|
|
Thanks thanks.
I am happy that it work already.
Problem of the setting in the hyperterminal.
I gonna learn and work on how to interface my pic and visual basic next. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Wed Mar 16, 2011 10:04 pm |
|
|
Do yourself a favor and download RealTerm -- (and I also use PuTTY which is an SSH/Telnet client with Serial abilities).
RealTerm is good for debugging stuff (as you can turn on char sets that show CTRL chars).
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
stacey
Joined: 14 Jan 2011 Posts: 22 Location: MY
|
|
Posted: Thu Mar 17, 2011 2:06 am |
|
|
Can I know what is the coding to send and receive signal from Visual Basic ?
The Visual Basic using is 2010 edition.
I found this on web
UART1_Init
UART1_Data_Ready
UART1_Tx_Idle
UART1_Read
UART1_Read_Text
UART1_Write
UART1_Write_Text
UART_Set_Active
But these all are for mC Pro.
Do this apply to CCS compiler also? |
|
|
|