I have use a controller for my system which reads an ADC and send to the PC via RS-232.
However, i found out that the sampling frequency is very low and i want it to be higher. I cant think of a way changing the time taken for the interface to do all the nesscessary stuff. seems like im quite stuck. hope you guys can help...
Below is my code attached for the ADC read and RS232 transmit subroutine.
;****** ADC Routine
adc_value
bcf PORTB,cs
clrf adc_buffer
movlw d'8'
movwf adc_count
loop2
btfsc PORTB,dataout
bsf STATUS,C
btfss PORTB,dataout
bcf STATUS,C
bsf PORTB,clk ;clock high
NOP
bcf PORTB,clk ;clock low
rlf adc_buffer,f
decfsz adc_count,f
goto loop2
bsf PORTB,cs
return
;***** RS 232(2) Transmit
Xmit_rs232
movwf Xmit_Byte
movlw 0x08
movwf Bit_Cntr
bcf ser_port2,ser_out2
call bit_delay
ser_loop2
rrf Xmit_Byte , f ;send one bit
btfss STATUS , C
bcf ser_port2,ser_out2
btfsc STATUS,C
bsf ser_port2,ser_out2
call bit_delay
decfsz Bit_Cntr,f ;test if all done
goto ser_loop2
bsf ser_port2,ser_out2 ;SEND STOP BIT
call bit_delay
return
bit_delay
movlw 0x18
movwf Delay_Count
bit_wait
nop
decfsz Delay_Count , f
goto bit_wait
return
Hope you all can help....
However, i found out that the sampling frequency is very low and i want it to be higher. I cant think of a way changing the time taken for the interface to do all the nesscessary stuff. seems like im quite stuck. hope you guys can help...
Below is my code attached for the ADC read and RS232 transmit subroutine.
;****** ADC Routine
adc_value
bcf PORTB,cs
clrf adc_buffer
movlw d'8'
movwf adc_count
loop2
btfsc PORTB,dataout
bsf STATUS,C
btfss PORTB,dataout
bcf STATUS,C
bsf PORTB,clk ;clock high
NOP
bcf PORTB,clk ;clock low
rlf adc_buffer,f
decfsz adc_count,f
goto loop2
bsf PORTB,cs
return
;***** RS 232(2) Transmit
Xmit_rs232
movwf Xmit_Byte
movlw 0x08
movwf Bit_Cntr
bcf ser_port2,ser_out2
call bit_delay
ser_loop2
rrf Xmit_Byte , f ;send one bit
btfss STATUS , C
bcf ser_port2,ser_out2
btfsc STATUS,C
bsf ser_port2,ser_out2
call bit_delay
decfsz Bit_Cntr,f ;test if all done
goto ser_loop2
bsf ser_port2,ser_out2 ;SEND STOP BIT
call bit_delay
return
bit_delay
movlw 0x18
movwf Delay_Count
bit_wait
nop
decfsz Delay_Count , f
goto bit_wait
return
Hope you all can help....