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