Roger Harrold
New Member
Hello, I'm new to the forum.
I have a problem using the simulator with the Hserout statement.
If I run my code on the simulator, transmitting 1, 2, 3, 4 or 5 bytes always results in the same Real Time Duration
value regardless of the Baud rate set in the Hseropen statement. I've tried 1200, 9600 & 19200.
The times between the two Break statements are as follows:
No. of Bytes.........Time (uS)
But as I increase the number of bytes, the extra time taken is always about 1mS per byte, regardless of Baud rate.
It seems as if the Baud rate is always about 9600. The simulator is set to 16MHz.
The SPBRG register contains the following values for each of the 3 Baud rates tried:
Baud ..........SPBRG
1200 ..........CF
9600 ..........19
19200 ........0CIf I run the code on the hardware, my comms. analyser tells me the baud rates are correct.
I'm obviously missing something, but I can't work out what it is.
Does anyone have any ideas, please?
(Sorry if some of the above formatting above looks a bit amateurish)
Code:
' PIC18F2520, 16MHz crystal clock
Define CLOCK_FREQUENCY = 16
Dim b0 As Byte
Dim b1 As Byte
Dim b2 As Byte
Dim b3 As Byte
Dim b4 As Byte
Hseropen 1200
Break
Hserout b0,b1,b2,b3,b4
Break
End
I have a problem using the simulator with the Hserout statement.
If I run my code on the simulator, transmitting 1, 2, 3, 4 or 5 bytes always results in the same Real Time Duration
value regardless of the Baud rate set in the Hseropen statement. I've tried 1200, 9600 & 19200.
The times between the two Break statements are as follows:
No. of Bytes.........Time (uS)
1...........Effectively zero
2...........Effectively zero
3...........1000
4.......... 2000
5.......... 3000
I understand the first two very short times, as the Tx hardware is buffering & transmitting without holding up the software.2...........Effectively zero
3...........1000
4.......... 2000
5.......... 3000
But as I increase the number of bytes, the extra time taken is always about 1mS per byte, regardless of Baud rate.
It seems as if the Baud rate is always about 9600. The simulator is set to 16MHz.
The SPBRG register contains the following values for each of the 3 Baud rates tried:
Baud ..........SPBRG
1200 ..........CF
9600 ..........19
19200 ........0C
I'm obviously missing something, but I can't work out what it is.
Does anyone have any ideas, please?
(Sorry if some of the above formatting above looks a bit amateurish)