2003-12-31 01:01 AM
Help needed on simple SCI program... why don't I get the same result back
2002-12-26 10:50 AM
code :
.include $SetupFileName segment 'Ram0' .MB DS.B 1 ; variabele byte op adres 80h segment 'Rom' ; Code segment - Address defined in device file (.str) ; Main Code here .main call ontvang call wachten call verstuur call wachten jra main .ontvang bset SCICR2,#2 ; RDI begint te zoeken naar een startbit wacht btjf SCISR,#5,wacht ; Wait for reception of a new byte ld A,SCISR ld A, SCIDR ld MB,A ret ; RDRF = hoog als 1 byte ontvangen is .wachten ld X,#255 w2 ld A,#255 w1 dec A jrne w1 dec X jrne w2 ret .verstuur bset SCICR2,#3 ld A,SCISR ld A,#$80 ld SCIDR,A wacht1 btjf SCISR,#7,wacht1 ld A,SCISR ld A,MB ld SCIDR,A wacht2 btjf SCISR,#7,wacht2 ret .include $VectorFileName ; Interrupt and Vector file (.stv) included here end This program first accepts 1 byte from the PC and than sends back #80 and the received byte MB to the PC... The problem is that do not get the value back that I've sent to the MCU. What is wrong? thanks chill@mine.be2003-12-31 01:01 AM
Hi,
the btjf SCISR,#x,wacht already performs an access to SCISR. You don't need to read it once again after the btjf, maybe this can disturb the communication. It's better to put the SCI initialisation in a dedicated routine (TE,RE can be set at a time cause SCI is full duplex). I attach a file written in C but containing in-line assembly. Hoping it will help! [ This message was edited by: stef on 31-12-2002 14:32 ] ________________ Attachments : Sci.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0As&d=%2Fa%2F0X0000000bW3%2F24XX0rFzE81VMmOx6ePTmPyV9ar9N14pfx0VK6fvWD8&asPdf=false