Kunal2
Junior Member level 3
Dear all
I am currently trying to simulate a program on PIC simulator IDE (Oshon software). The program compiled without any error in MikroBasic. Leds are flashing at port b.1 at intervals showing information reception but on the soft uart simulation interface, nothing is appearing. However when i tried the program with USART it works both in simulation and real life. I am posting both codes. Can you please help me out?
Kind regards
Kunal
Soft Uart Program
program USARTCOMM_part1 'this program will send hex value 88 continuously
I am currently trying to simulate a program on PIC simulator IDE (Oshon software). The program compiled without any error in MikroBasic. Leds are flashing at port b.1 at intervals showing information reception but on the soft uart simulation interface, nothing is appearing. However when i tried the program with USART it works both in simulation and real life. I am posting both codes. Can you please help me out?
Kind regards
Kunal
Soft Uart Program
Code:
program soft_uart_1
dim received_byte as byte
main:
TRISB=$01 'defining portb.1 as ouput(TX) and portb.0 as input(RX)
PORTB=0 'setting portb as output
Soft_Uart_Init(PORTB, 1, 2, 9600, 0) ' Initialize soft UART
received_byte=$80
eloop:
soft_Uart_Write(received_byte) ' Send data via UART
delay_us(3000)
goto eloop
end.
program USARTCOMM_part1 'this program will send hex value 88 continuously
Code:
dim result as byte ' defining variable to contain
' adc result to transmit as byte
'main program of transmission
main :
'result = $00
result = $80
Usart_init(9600)'using NRZ(non return zero) format with 1 start bit, 8 data bits
'and 1 stop bit
TRISC= $C0 'transmitting along bit 7 and receiving along bit 6 of port C
TXSTA = $24 'Bit 7 =0 CSRC (Don't Care)
'Bit 6 =0 TX9=0
'Bit 5 =1 TXEN=1
'Bit 4 =0 SYNC=0
'Bit 3 =0
'Bit 2 =1 BRGH=1
'Bit 1 =0
'Bit 0 =0
loop:
'result= result+1
Usart_Write(result)
delay_us(500)
goto loop
end.
Last edited: