PIC18F4550 Soft_UART problem

Status
Not open for further replies.

mrsalesi

Newbie level 5
Joined
Jun 12, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
mrsalesi
Activity points
1,339
Hi all,
I have some working code for other PIC family(like pic16fxx).
and i programming in MicroCforPIC IDE and proteus simulator.
Bu it is not sending and receiving any thing in terminal.

I check frequency and baud rate . I don't know .
this is my code:

-----------------------------------------------------------------------------------

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
char i, error, byte_read;                 // Auxiliary variables
 
void main(){
 
  ADCON1 |= 0x0F;                          // Configure AN pins as digital I/O
  CMCON  |= 7;
 
  TRISB = 0x00;                           // Set PORTB as output (error signalization)
  PORTB = 0;                              // No error
 
  error = Soft_UART_Init(&PORTC, 7, 6, 9600, 0); // Initialize Soft UART at 14400 bps
  if (error > 0) {
    PORTB = error;                        // Signalize Init error
    while(1) ;                            // Stop program
  }
  Delay_ms(1000);
 
  for (i = 'z'; i >= 'A'; i--) {          // Send bytes from 'z' downto 'A'
    Soft_UART_Write(i);
    Delay_ms(1000);
  }
 
  while(1) {                              // Endless loop
    byte_read = Soft_UART_Read(&error);   // Read byte, then test error flag
    if (error)                            // If error was detected
      PORTB = error;                      //   signal it on PORTB
    else
      Soft_UART_Write(byte_read);         // If error was not detected, return byte read
    }
}


-----------------------------------------------------------------------------------

and this is all project(MicroC+ proteus ) and Schematic image .
==========================================

==========================================

View attachment PIC18F4550_softwareUart.zip


Thank alot
 
Last edited by a moderator:

Hi,

Cannot help with the C code, but wonder why you are not using the inbuilt hardware Usart which is much easier to use ..
 

Hi

thanks for your attention.However i respect for you,but this is not my answer.
I have my reason .

best regard.
 


Code C - [expand]
1
TRISC = 0x80;



In code you are using PORTC for SoftUART but in Circuit using PORTA. Change hardware connection to PORTC pins 6 and 7.


Code C - [expand]
1
Soft_UART_Init(&PORTC, 7, 6, 9600, 0); // Initialize Soft UART at 14400 bps




Working file attached.

 

Attachments

  • PIC18F4550 SoftUART.rar
    95.8 KB · Views: 36
  • softUART.png
    41.3 KB · Views: 57
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…