Andrew Farrar wrote: > > Hello, > > I have a time critical application where each bit to be sent out > serially is to have duration of 69uS (.02/288 to be precise, but 69uS > will do). I have a routine for serial transmission, modified from > the embedded control applications book. However, I wish the time for > each bit to be the same duration. Is there a good way of doing this? > Also when fetching another data byte to be sent and then converting > serially, although I expect some padding can be done when sending > bits to allow for the overhead involved in fetching the next byte. > > Can a simple modification be done to the code that I have: > > ; FILE SAVED AS MAGIC2.ASM > ; MAGIC1.ASM HAS BEEN TRASHED > > ; FOR PIC 16C84 > > CBLOCK 0X00 > INDF,RTCC,PC,STATUS,FSR,PORTA,PORTB > ENDC > > BIT_COUNT EQU 08H > BYTE_COUNT EQU 0CH > > DATA0 EQU 09H TEMP EQU 0DH ;tempor.data reg > > F EQU 1 > W EQU 0 > > Z EQU 2 ;ZERO FLAG > C EQU 0 ;CARRY FLAG > > #DEFINE TX_0 PORTB,7 ; THIS IS SINE + 0 LINE > > ;**************IT STARTS HERE***************** > > ORG 0 > GOTO START > > ORG 30 > > START CLRW ; PUT 0 IN WORK REG > TRIS PORTB ; SET UP PORTB ALL OUTPUTS > TRIS PORTA ;PORT A AS ALL OUTPUTS AS WELL > > MOVLW 0 > MOVWF BYTE_COUNT > > NEXT_BYTE > MOVLW .8 > MOVWF BIT_COUNT ;START BIT COUNT AT 8 (TO GO) > MOVLW .3 ; MODIFY LATER, SORT ONE BIT OUT AT A TIME ! > CALL MAGIC ; AFTER WHICH W CONTAINS FIRST BYTE OF DATA > MOVWF DATA0 > > ;TRANSMIT SECTION > > SEND_ANOTHER_BIT clrf TEMP > RLF DATA0,F ; CARRY FLAG TO CONTAIN SERIAL DATA > BTFSC STATUS,C bsf TEMP,7 ;as TX_0 movf TEMP,W movwf PORTB ; BSF TX_0 ;TRANSMIT A ONE ; BTFSS STATUS,C ; BCF TX_0 ;TRANSMIT A ZERO > DECFSZ BIT_COUNT,F > GOTO SEND_ANOTHER_BIT > GOTO NEXT_BYTE > > MAGIC ADDWF PC,F ; ADD OFFSET TO PC AND GET MAGIC DATA > RETLW 000h > RETLW 090h > RETLW 034h > RETLW 0C3h > RETLW 0E6h > RETLW 0BBh > RETLW 0DDh > RETLW 0F7h > RETLW 0F7h > > END > > The program is by no means complete but any help or suggestions, on > the problem of a '1' having duration of 10uS and a '0' of 6uS would > be appreciated, please correct me if these figures are wrong! > > NB C3 was chosen for now as all being well this should give a square > wave if repeated 1100 0011 1100 0011 1100 0011. > > Many thanks for getting this far, hope very much that you can help. > > Cheers > > Andy Farrar > asf@ee.port.ac.uk B.R. Vladimir