Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] uart problem with pic 18f6620

Status
Not open for further replies.

pfe

Newbie level 3
Joined
Apr 24, 2016
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
18
Hello,
I want to use uart with pic 18f6620 but the virtual terminal doesn't receive the word that i send. help me please to solve this problem.


This is my code written with mikroc.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void main() 
{ txsta1.sync=0; //
txsta1.txen=1; // 
rcsta1.spen=1 ;RCSTA1.CREN = 1; //
 
trisc.f6=0;
trisc.f7=1;
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
 
UART1_Write_Text("start");
UART1_Write(10);
UART1_Write(13);
 
}

 

Attachments

  • uart.PNG
    uart.PNG
    56.8 KB · Views: 92
Last edited by a moderator:

While not utilizing MikroC, there are several issues which should be mentioned.

What are the current configuration register settings? Has the watchdog timer been disabled?

What is the actual System Clock Frequency (Fosc)? Has the PLL been enabled? Has the Fosc been entered into the proper MikroC setting? I suspect the UART routines rely on the correct Fosc being known.


Also, you should always prevent code execution from exiting main() with the use of a Superloop:


Code:
while(1)
{
}

positioned after the last statement within main().



BigDog
 

Hi,

but the virtual terminal doesn't receive the word that i send.
Does it receive nothing at all, or does it receive garbage?

Klaus
 

fonfiguration.PNG

This is Mikroc setting

- - - Updated - - -

It dosn't receive the correct word. It receives dushs (-------)
 

If you are using MAX485 for communication then there is read-write control pin. You have to make that pin high for writing to UART terminal.
 

Hi,

You should post your corrected code.

***
It dosn't receive the correct word. It receives dushs (-------)
this means 7 x "-" = 7 bytes.

You try to send 7 bytes: "start" & [0x0A] & [0x0D].

Hmm. Intersting.
Are you sure both receiver and transmitter are configured for
* 9600 baud
* 8-N-1
* no handshake
* same voltage levels (logic/RS232)
* ASCII
* same polarity (idle = high)?

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top