I'm using VB6 to communicate with PIC via RS-232.
RS-232 -> MAX-232 -> PIC
I have tested the output of the MAX-232 by sending character using VB6. I observed the output through oscilloscope. It works! But when i connected the MAX-232 to the PIC and try a simple program by sending a character and if the character is matched, it will ON the LED. But it is not working.
My VB6 setting is 9600=baud rate N=no parrity 8bits 1 stop bit
Here my code:
Do u guys have any idea of what's going on?
Hope to hear from u guys!
Thanks in advance!
RS-232 -> MAX-232 -> PIC
I have tested the output of the MAX-232 by sending character using VB6. I observed the output through oscilloscope. It works! But when i connected the MAX-232 to the PIC and try a simple program by sending a character and if the character is matched, it will ON the LED. But it is not working.
My VB6 setting is 9600=baud rate N=no parrity 8bits 1 stop bit
Here my code:
Code:
;Test
LIST p=16F628A ;tell assembler what chip we are using
include "P16F628A.inc" ;include the defaults for the chip
ERRORLEVEL 0, -302 ;suppress bank selection messages
__config 0x3D18 ;sets the configuration settings (oscillator)
cblock 0x20 ;start of general purpose registers
count
KM Equ 0
org 0x0000
movlw 0x07
movwf CMCON ;turn comparators off
Initialise clrf count
clrf PORTA
clrf PORTB
SetPorts bsf STATUS, RP0 ;select bank 1
MOVLW B'00000110'
MOVWF TRISB
bcf STATUS, RP0 ;select bank 0
call SER_INIT
CHECK call Rcv_RS232 ;check receive data
xorlw 'B'
btfss STATUS, Z ;is data 'B'?
goto CHECK ;if not, goto CHECK
goto KM_ON ;if yes. goto KM_ON
KM_ON bsf PORTB, KM ;ON Keypad Message
:Hardware USART Serial Routines
SER_INIT
BSF STATUS, RP0 ;select bank 1
MOVLW d'25' ;9600 baud @ 4 Mhz Fosc +0.16% err
MOVWF SPBRG
MOVLW b'00100100' ;BRGH = 1
MOVWF TXSTA ;enable Async Transmission, set brgh
BCF STATUS, RP0 ;select bank 0
MOVLW b'10010000'
MOVWF RCSTA ;enable Async Reception
RETURN
XMIT_RS232 btfss PIR1, TXIF ;xmit buffer empty?
GOTO XMIT_RS232 ;no, wait
MOVWF TXREG ;now send
RETURN
Rcv_RS232 BTFSS PIR1, RCIF ;check for received data
GOTO Rcv_RS232
MOVF RCREG, W
RETURN
;End of serial routines
Hope to hear from u guys!
Thanks in advance!