Native Serial code on TINI
"Andreas Skaar" <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <[email protected]> |
I am doing a 3rd year project where I am trying to control a Marklin train set. I hope to do this by using the serial port on the TINI board. I have had some success with using the java library to send the data to the train set. But I have run in to a timing issue and java doesnt seem to give me enough control over the system. I need to have a break for a couple of hundred micro seconds which I cant do in java. So I have started to research how to do it using native code. I have written the following program to test the serial port in native mode $include(tini.inc) $include(ds80c390.inc) $include(tinimacro.inc) $include(apiequ.inc) Serial_Init: clr a ret Native_method1: send: MOV sbuf1, #0ffh CALL POUT MOV SBUF1, #000h CALL POUT MOV SBUF1, #0ffh CALL POUT MOV SBUF1, #000h CALL POUT MOV SBUF1, #0ffh CALL POUT MOV SBUF1, #000h CALL POUT MOV SBUF1, #0ffh CALL POUT MOV SBUF1, #000h CALL POUT MOV SBUF1, #0ffh CALL POUT MOV SBUF1, #000h CALL POUT MOV SBUF1, #0ffh CALL POUT MOV SBUF1, #000h CALL POUT MOV SBUF1, #0ffh CALL POUT MOV SBUF1, #000h CALL POUT MOV SBUF1, #0ffh CALL POUT MOV SBUF1, #000h CALL POUT MOV SBUF1, #0ffh CALL POUT MOV SBUF1, #000h ;******** Send finished ********* MOV R0, #003h ;just a test value MOV R1, #0h MOV R2, #0h MOV R3, #0h CLR A ; No errors RET ; Exit from Program ;************** Function for waiting between sending bytes ****************** POUT: JNB TI1, POUT ; Wait here until TI bit is set CLR TI1 ; Clear TI for next byte RET ; Return END I create a serial port object in the java code to set up the serial port. I then want to use the code above to send data bytes. But at the moment the code seems to be sending random stuff. And if I try to run the above code more than 2 times without restarting the TINI board the board sends random bytes after the program has finished. Can anyone tell me what I am doing wrong with my assembly code? _________________________________________________________________ Tired of 56k? Get a FREE BT Broadband connection http://www.msn.co.uk/specials/btbroadband _______________________________________________ TINI mailing list TINI-6tN4nzCoH/[email protected] To UNSUBSCRIBE, edit your profile, or see list archives: http://lists.dalsemi.com/mailman/listinfo/tini