pic16f690 - assembly codes of the two channel ADC

Status
Not open for further replies.

adulfo

Newbie level 5
Joined
Jan 23, 2010
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,374
Good day guys...
Please help me in the assembly codes of the two channel ADC and the output sof the ADC would be transmitted to via EUSART (Async Mode) to the PC. Thanks guys...
 

pic16f690

i dont think you may get any assistance here, for such un-specific demands.
 

Re: pic16f690

I have two sensors, each of the output of the sensors are to be converted to digital to be sent to PC for monitoring. At the beginning of the operation, the PC will send a high pulse to the one of the pin of the PIC to trigger the relay to turn on our oven. As the operation goes by, the PIC would send the digital output( from the two sensors) to the PC for graphing until such time the desired output have been attained. This is an automated soil dryer oven. Just me me guys to give the step by step on how to implement this using the PIC16f690 possibly in assembly codes. Thanks.
 

Re: pic16f690

Here is my intial codes guys. Please advice me on what to do next or tell me where I went wrong on the coding.


#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
errorlevel -302

;******* Start at the reset vector
Cblock 0x20
temp ; Assign an address to hold receive signal

endc
org 0x000


Start
org 0x010
clrf PORTC

bCf STATUS,RP0 ;bank 1
bsf STATUS,RP1
;****************************************************
movlw b'10101111'
movwf TRISB ;portB [Pin 11 & Pin 13] outputs** <5,7> set for RX/TX

;**********************************************
Receive:
bCf STATUS,RP0 ;bank 1
bSf STATUS,RP1
movlw d'25' ; Set Baud rate, 9600 BPS
movwf SPBRG
bcf BAUDCTL,4 ;transmit non-inverted data to pin RB7
bcf BAUDCTL,3 ;use 8 bit baud generator BRG16
bcf BAUDCTL,1 ;edges do not generate interrupts
bcf BAUDCTL,0 ;disables auto-baud ABDEN
bCf STATUS,RP0 ;bank 0
bcf STATUS,RP1
bcf RCSTA,RX9 ; 8 BIT RECEPTION
bsf RCSTA,CREN ;ENABLES RECEIVER
bsf RCSTA,SPEN ;**** Serial ENABLED
bsf PIR1,TXIF ;**Set interrupt
movf RCREG,temp ; move data of rcreg to temp
bCf STATUS,RP0 ;bank 1
bSf STATUS,RP1
movwf TRISB ;drive the relay at Pin 11 or Pin 13
btfsc TRISB,6 ; test if Pin11 is high
goto Receive ; loop until Pin 11 will be high




Init_ADC
; Set ADCON0


bcf STATUS,RP0 ; Go to Bank 0
bcf STATUS,RP1
movlw b'10000001' ;Right justified, VDD reference bit,pin ANO(pin19), intialize ADC
movwf ADCON0
; Set ADCON1
BANKSEL ADCON1 ; this could be done using this bCf STATUS,RP0 bank 1 bSf STATUS,RP1
movlw b'10000101' ; A/D clock conversion clock FOSC/2
movwf ADCON1
BANKSEL ADCON0
return
Read_ADC
bsf ADCON0, GO_DONE ;initiate conversion
btfsc ADCON0, GO_DONE
goto $-1 ;wait for ADC to finish

movf ADRESH,W
andlw 0x03
movwf NumH
BANKSEL ADRESL
movf ADRESL,W
BANKSEL ADRESH
movwf NumL ;return result in NumL and NumH
return


;**********************************************
Main
movlw 0x0f ; not the correct data to be transmitted
movwf TXREG

;********************************************
Wait
btfss PIR1,TXIF
goto Wait ;/**********TXIF will get clear by loading TXREG
goto Buffer

;/*********Ready to load another 8-bit value??*****
Buffer
btfss TXSTA,TRMT
goto Buffer
goto Nextvalue

;/********Next value to be transmit*****

Nextvalue
movlw 0xff
movwf TXREG

Wait1
btfss PIR1,TXIF
goto Wait1 ;/******TXIF will get clear by loading TXREG
goto Buffer1

;/**************
Buffer1
btfss TXSTA,TRMT
goto Buffer1
goto Main



END
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…