I'm having a small problem with the hsersend routine. I developed a serial port for Amstrad CPC using a PIC16F1579. Until recently, everything works ok, but when i installed the latest version of cowbasic compiler and recompile the program, i encountered HUGE delays on transmissions (receive of data was ok though)!
For example, a 16Kb file which used to be transferered from amstrad to PC in ~4seconds, now needed more than 25seconds!
After a lot of research, i finally discovered that the assembly code produced between older and new versions, was different. Older version gives this asm code for Hserreceive:
HSERSEND
;Block before sending (if needed)
;Send byte
;if comport = 1 Then
decf COMPORT,W
btfss STATUS, Z
goto ENDIF28
;HSerSendBlocker
;Wait While TXIF = Off
SysWaitLoop1
btfss PIR1,TXIF
goto SysWaitLoop1
;TXREG = SerData
movf SERDATA,W
banksel TXREG
movwf TXREG
;exit sub
banksel STATUS
return
;end if
ENDIF28
return
New version however gives this code:
HSERSEND
;Block before sending (if needed)
;Send byte
;Registers/Bits determined by #samevar at top of file
;if comport = 1 Then
decf COMPORT,W
btfss STATUS, Z
goto ENDIF34
;HSerSendBlocker
;asm showdebug TXREG equals SerData below will assign SerData to TXREG or TXREG1 or U1TXB via the #samevar
;txreg equals serdata below will assign serdata to txreg | txreg | txreg via the #samevar
;
;TXREG = SerData
movf SERDATA,W
banksel TXREG
movwf TXREG
;Add USART_DELAY After all bits are shifted out
;Wait until TRMT = 1
SysWaitLoop1
btfss TXSTA,TRMT
goto SysWaitLoop1
;Wait USART_DELAY
movlw 1
movwf SysWaitTempMS
clrf SysWaitTempMS_H
banksel STATUS
call Delay_MS
;exit sub
return
;end if
ENDIF34
return
Obvioulsy the added delay_ms routine (which obviously adds 1ms delay) for EVERY byte sent, is what caused the problem. And even when i tried to remove the USART_BLOCKING command, hserreceive still gave me the same code with the added 1ms delay.
So, as this is causing unneccesary big delays in data transfer (there was no problem in transfers with the old code) , i'd like to ask if there is a way to remove this 1ms delay for hsersebd code, or at least if i could set it in less values in the microsecond range.
Thanks,
John.
Last edit: ikonsgr74 2019-01-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, it worked!
It seems that in latest version, the deafult set for delay on serial send was changed, as i never had to use this directive in the past.
Thanks WIlliam! ;-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The library was just updated so that the delay began AFTER all the bits were shifted out of the TX register. As it was, there was little or no delay at baud rates at or below 9600, because the delay was completed before the all the bits were shifted out.
Now the default and any user defined delay period will be very accurate at any baud rate.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone and Happy new year!
I'm having a small problem with the hsersend routine. I developed a serial port for Amstrad CPC using a PIC16F1579. Until recently, everything works ok, but when i installed the latest version of cowbasic compiler and recompile the program, i encountered HUGE delays on transmissions (receive of data was ok though)!
For example, a 16Kb file which used to be transferered from amstrad to PC in ~4seconds, now needed more than 25seconds!
After a lot of research, i finally discovered that the assembly code produced between older and new versions, was different. Older version gives this asm code for Hserreceive:
HSERSEND
;Block before sending (if needed)
;Send byte
;if comport = 1 Then
decf COMPORT,W
btfss STATUS, Z
goto ENDIF28
;HSerSendBlocker
;Wait While TXIF = Off
SysWaitLoop1
btfss PIR1,TXIF
goto SysWaitLoop1
;TXREG = SerData
movf SERDATA,W
banksel TXREG
movwf TXREG
;exit sub
banksel STATUS
return
;end if
ENDIF28
return
New version however gives this code:
HSERSEND
;Block before sending (if needed)
;Send byte
;Registers/Bits determined by #samevar at top of file
;if comport = 1 Then
decf COMPORT,W
btfss STATUS, Z
goto ENDIF34
;HSerSendBlocker
;asm showdebug TXREG equals SerData below will assign SerData to TXREG or TXREG1 or U1TXB via the #samevar
;txreg equals serdata below will assign serdata to txreg | txreg | txreg via the #samevar
;
;TXREG = SerData
movf SERDATA,W
banksel TXREG
movwf TXREG
;Add USART_DELAY After all bits are shifted out
;Wait until TRMT = 1
SysWaitLoop1
btfss TXSTA,TRMT
goto SysWaitLoop1
;Wait USART_DELAY
movlw 1
movwf SysWaitTempMS
clrf SysWaitTempMS_H
banksel STATUS
call Delay_MS
;exit sub
return
;end if
ENDIF34
return
Obvioulsy the added delay_ms routine (which obviously adds 1ms delay) for EVERY byte sent, is what caused the problem. And even when i tried to remove the USART_BLOCKING command, hserreceive still gave me the same code with the added 1ms delay.
So, as this is causing unneccesary big delays in data transfer (there was no problem in transfers with the old code) , i'd like to ask if there is a way to remove this 1ms delay for hsersebd code, or at least if i could set it in less values in the microsecond range.
Thanks,
John.
Last edit: ikonsgr74 2019-01-02
Thank you. We will look into this urgently.
We did make a change, as you have reported. But, the movement of the wait into the HSERSEND method is not optimal.
Ok, thanks!
Hi John
The delay defaults to 1 ms to allow error free comms to most terminal programs. Try adding the following to your source code. Then retest.
William
Yes, it worked!
It seems that in latest version, the deafult set for delay on serial send was changed, as i never had to use this directive in the past.
Thanks WIlliam! ;-)
The default 1 ms dealy was not really changed.
The library was just updated so that the delay began AFTER all the bits were shifted out of the TX register. As it was, there was little or no delay at baud rates at or below 9600, because the delay was completed before the all the bits were shifted out.
Now the default and any user defined delay period will be very accurate at any baud rate.