Hi all,
I'm transferring data between my PC (running a tcl programme) and a 28X2 (utilising the HSERIN/HSEROUT pair of pins), connectivity being via an AXE027. It's early days yet and there's a lot of debugging ahead of me, but basic two way communication is working. One problem I am facing is the reception of data into the 28X2's scratch pad. This is going to the default location of 0x000, where it is overwriting and corrupting data for transmission. It strikes me that there are two possible solutions to this. One is to re-locate the area of the scratch pad used for storing data for transmission away from that being used for reception. I am very reluctant to do this, however, as it will add a lot of complexity to the programme. The second solution would be to receive to a location in the scratch pad that is away from that being used for transmission data. At face value this should be trivial since the HSERIN command supports an argument defining the first location in the scratch pad that received data is dumped to. At this point I run into a very different problem.
A search of the programme reveals that the command HSERIN is not present! I have a vague memory that the code for receiving via HSERIN was given to me from this forum (Hippy, perhaps?) some while back, the consequence being that reception occurs by some arcane process that I do not have a good understanding of. I'll append the relevant sections of code, which needs to be modified to receive to a user-defined scratch pad location. Thanks for any help.
I'm transferring data between my PC (running a tcl programme) and a 28X2 (utilising the HSERIN/HSEROUT pair of pins), connectivity being via an AXE027. It's early days yet and there's a lot of debugging ahead of me, but basic two way communication is working. One problem I am facing is the reception of data into the 28X2's scratch pad. This is going to the default location of 0x000, where it is overwriting and corrupting data for transmission. It strikes me that there are two possible solutions to this. One is to re-locate the area of the scratch pad used for storing data for transmission away from that being used for reception. I am very reluctant to do this, however, as it will add a lot of complexity to the programme. The second solution would be to receive to a location in the scratch pad that is away from that being used for transmission data. At face value this should be trivial since the HSERIN command supports an argument defining the first location in the scratch pad that received data is dumped to. At this point I run into a very different problem.
A search of the programme reveals that the command HSERIN is not present! I have a vague memory that the code for receiving via HSERIN was given to me from this forum (Hippy, perhaps?) some while back, the consequence being that reception occurs by some arcane process that I do not have a good understanding of. I'll append the relevant sections of code, which needs to be modified to receive to a user-defined scratch pad location. Thanks for any help.
Code:
; Define the sub-routine for receiving messages from the PC.
task_pc_receive:
LET RxPointer = HSERPTR
LET RxMessageLen = 0x00
DO WHILE RxMessageLen = 0x00
GET RxPointer, RxMessageLen
IF RxMessageLen = "?" THEN ; Do we have anything to transmit?
IF TxPointer = TxCounter THEN ; Nothing to transmit.
HSEROUT 0, ("&") ; Send NACK.
ELSE ; Something to transmit.
HSEROUT 0, ("!") ; Send ACK.
LET Status = Status OR 0x80
ENDIF
; ELSE
; FOR TempRx01 = 1 TO RxMessageLen ; Receive <MessageLen> bytes of data.
; GET TempRx01, RxPCData ; Data must be processed.
; NEXT TempRx01
; HSEROUT 0, ("!")
ENDIF
LOOP
RETURN
...<various bits of code until the HSER interface is set up and the sub-routine is called>...
; Set up the hardware serial data and I2C interfaces.
HSERSETUP B9600_16, 0x07
HI2CSETUP I2CMASTER, 0xA0, I2CSLOW_16, I2CBYTE
; The red LED being lit is the signal for the user to start the TCL script.
; We now wait for the question mark to arrive.
GOSUB task_pc_receive