Hi Folks,
I need a little help with this task. I want to read data from Ultrasonic distance meter which put out every 100ms serial data.
The protocol is here:
The captured data looks like:
My program trying to capture this data looks like:
Code:
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
__config _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_ON & _BORV_19 & _LVP_OFF
#ENDCONFIG
;MCU PIC 12F1840
DEFINE OSC 4 ; Use internal clock 4MHz
OSCCON = %01101010 ; 4 MHz internal
OSCTUNE = %00000000 ; Internal osc tunning
TRISA = %100000 ; RA.5 input rest output
ANSELA = %00000
OPTION_REG.7=1 ; disable internal pull-ups
APFCON = %10001100
string var byte[16]
' Set receive register to receiver enabled
DEFINE HSER_RCSTA 90h
' Set transmit register to transmitter enabled
DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 9600
clear
start:
hSerin 100,start,[wait ($ff),str string\16]
pause 100
HSEROUT [hex string,13,10]
pause 500
goto start
obviously it doesn't work because my poor programming skills.
I searched the forum to find something to point me how to capture these data but no success.
Can someone point me how to do that?
Thanks,
Louis
Bookmarks