I need help on ADC interrupt


Results 1 to 6 of 6

Threaded View

  1. #3
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: I need help on ADC interrupt

    Hi macrackit,
    Sorry for that my mistake...here is the whole code, I'm using Pic16F877A with 20mhz crystal
    Code:
    clear
    INCLUDE "MODEDEFS.BAS"       ' Include Shiftin/out modes
    
    
    pause 4000 
    
    
    '@ DEVICE HS_OSC
    DEFINE   OSC 20
    Define ADC_BITS     8   ' Set number of bits in result
    Define ADC_CLOCK    3   ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50  ' Set sampling time in uS
    
    
    adval1 Var Byte          ' Create adval to store result
    adval2 Var Byte
    adval3 Var Byte
    
    
    TRISA = 111111    ' Set PORTA to all input
    ADCON1 = 000010   ' Set PORTA analog
    
    
            
    TRISC  = 000000    ' PORTC.7 is the RX input, PORTC.6 is the TX output
    TRISD  = 000000    
    led0       var     PORTD.0
    led1       var     PORTD.1
     ' The following codes is for bluetooth------------------------------------------------------------------------------------
     SerOut2 PortC.6,84, [$02,$52,$27,$06,$00,$7F,$12,$13,$23,$17,$09,$00,$03]
     pause 200
     SerOut2 PortC.6,84, [$02,$52,$66,$00,$00,$B8,$03]
     pause 200
     Serout2 PortC.6,84, [$02,$52,$04,$11,$00,$67,$10,$4D,$49,$43,$52,$4F,$42,$4F,$58,$42,$54,$31,$20,$20,$20,$20,$00,$03]
     '-------------------------------------------------------------------------------------------------------------------------
     RX var byte ' Receive byte
    
    
    
    
    mainloop:
       ADCIN 0, adval1       ' Read channel 0 to adval1
       ADCIN 1, adval2       ' Read channel 1 to adval2
       
       pause 20
       Pause 100            ' Wait .1 second
       if adval1 >25 then
       SerOut2 PortC.6,84, ["1"]    ' sends 1 to Bluetooth TX
       Serout PortD.2,T9600, [$1B,$45,"[1] ",#adval1]   ' Displays to serial LCD for debugging
       Pause 100
       Endif 
       if adval2 >25 then
       SerOut2 PortC.6,84, ["2"]   ' sends 2 to Bluetooth TX
       Serout PortD.2,T9600, [$1B,$45,"[2] ",#adval2]   ' Displays to serial LCD for debugging
       Pause 100
       Endif 
      
       Goto mainloop        ' Do it forever
    My problem is how to receive incoming data from bluetooth with SERIN without freezing the application..

    regards,
    tacbanon
    Last edited by tacbanon; - 18th December 2011 at 09:43.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts