CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Need help on how to start the UART

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stacey



Joined: 14 Jan 2011
Posts: 22
Location: MY

View user's profile Send private message

Need help on how to start the UART
PostPosted: Wed Mar 16, 2011 7:16 pm     Reply with quote

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

View user's profile Send private message

Re: Need help on how to start the UART
PostPosted: Wed Mar 16, 2011 7:32 pm     Reply with quote

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

View user's profile Send private message

Re: Need help on how to start the UART
PostPosted: Wed Mar 16, 2011 8:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 16, 2011 8:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 16, 2011 9:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 16, 2011 10:04 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 17, 2011 2:06 am     Reply with quote

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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group