--=-KboKlRHil05vI/ExyFYg Content-Type: text/plain Content-Transfer-Encoding: 7bit I have the following program that is supposed to, at reset, send the character "A" at 9600 bit/sec on the PB7 pin. I do not get anything back :( Any ideas ? Amaury ;; program to send 'A' on the serial port ;; list f=INHX8M, p=16F84 __config 0x1ff9 ;; status register status equ 0x07 ; status register rp0 equ 5 ; carry equ 0 ; the carry bit ;; port B configuration portb equ 0x06 ; I/O port B serio equ 7 ; the serial i/o is RB7 sda equ 5 ; SDA is RB5 scl equ 4 ; SCL is RB4 trisb equ 0x86 ; trisb is the direction register for port B ;; serial bus buffers/counters sobuf equ 0x0c ; serial output buffer sibuf equ 0x0d ; serial input buffer sctr equ 0x0e ; counter for bits to output to serial port delay equ 0x0f ; wait counter for serial i/o ;; beginning of the program ;; jump over the interrupt vector org 0 init goto start ;; interrupt vector ;; do nothing org 4 intr retfie ; do nothing if an interuption occurs start bcf status, rp0 ; select bank 0 clrf portb ; clears port B bsf status, rp0 ; select bank 1 movlw 0x00 ; all pins in output position movwf trisb ; sets direction for all pins to "output" movlw 'A' ; character 'A' movwf sobuf ; stores the character in the buffer call ssbyte ; sends a byte sleep ; stops the program ;; sends a byte ;; gets the byte in the W register ;; output pin is RB7 ;; first, send the start bit ssbyte btfsc portb, serio ; tests if the serial i/o was up goto stbit ; no, create a stop bit bsf portb, serio ; sets portb so that we have a stop bit call swbit ; waits for the lenght of a bit stbit movlw 8 ; 8 bits to send movwf sctr ; move to counter register bcf portb, serio call swbit ;; first, shift the buffer through the carry sbitlp rrf sobuf, 1 ; btfsc status, carry ; test the carry goto sbset ; the bit is set ;; the bit is clear bcf portb, serio ; clear the bit goto sbwait ; go to the wait call ;; the bit is set sbset nop ; cycle bsf portb, serio ; set the bit sbwait call swbit ; wait ;; decrement the counter decfsz sctr, 1 ; one bit done ! goto sbitlp ; no, still some bits ;; TODO : now, insert parity ;; stop bit bsf portb, serio ; stop bits are up call swbit ; wait to the end of the bit return ; do nothing at the moment ;; wait for 104 cycles (1 bit) ;; 7 cycles used swbit movlw 0x2E ; load counter movwf delay ; ;; 9 cycles used. 95 remaining swblp decfsz delay, 1 ; decrement counter +1 goto swblp ; loop +1 return ; this is supposed to wait for 1/9600 of a second end --=-KboKlRHil05vI/ExyFYg Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KVmVyc2lvbjogR251UEcgdjEuMC42IChHTlUv TGludXgpCkNvbW1lbnQ6IEZvciBpbmZvIHNlZSBodHRwOi8vd3d3LmdudXBnLm9yZwoKaUQ4REJR QTdnQm5BT3hkQ3UxdzZZMzhSQXRCckFKOW10MGVydENnZ0h1OWoyS2ZoYlhQSHRSZ2lhUUNnc1hk dApIOW9ESm55eFBuNld4eEZlYUNvZ21xbz0KPWJDUjEKLS0tLS1FTkQgUEdQIFNJR05BVFVSRS0t LS0tCg== --=-KboKlRHil05vI/ExyFYg-- -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu