; SMILENGHEADER ; COMMENT This is the Smile NG file header, do not modify! ; VERSION 1.0 ; PROC CALM \title;Program A/D converter test ;Potmetre 5kOhm ;Cursor sur pin RA0 ;Extremités sur 0V et +5V, pin 1-2 ; ; Valeur du pot affiché en binaire sur le port B .Proc 16F870 .Ref 16F870 .list 0 .Ins 16F870M.asi .endlist \var; .Loc DebVar Hi_Count: .BLK.16 1 Lo_Count: .BLK.16 1 \const; Constantes IniAdConLeft =2'00001110 ;Define Analogue Pin Low Byte ;IniAdConLeft =2'10001110 ;Define Analogue Pin Hi Byte SelAd0 =2'00000001 ;Start A/D module Bdir =0 ;defined in reference file ;Go ;AdResH .loc 0 \prog;Main init: Bank0to1 Move #IniAdConLeft,W Move W,Adcon1 Move Bdir,W Move W,TrisB Bank1to0 GetAd0: Move #SelAd0,W Move W,Adcon0 Call Del20 Set Adcon0:#Go A$: TestSkip,BC AdCon0:#Go ;wait for ad conversion done Jump A$ Move AdResL,W ;get High byte of the AD conversion ;low byte in Bank1 ! Move W,PortB ;Afficher le resultat sur le port Jump Getad0 Del20: ;WAIT 20ms ; enter here for fixed 1 ms (.001 second) delay Move #200,W ;(1) load 10 into W register v_delay: ; enter here for delay with desired ms*10 in W (max 25.5ms) Move W,Hi_count ;(1) (i.e. for 20 ms delay W = .200)(.1ms resolution) loop1: Move 31,W Move W,Lo_count ;(1) loop2: DecSkip,EQ Lo_count ; (30x3)+2 = 92 cycles (4MHz = 1 uS per instruction cycle) Jump loop2 ;/ Nop ;(1) DecSkip,EQ Hi_count ;(1) Jump loop1 ;(2) ret .end