SILLION BUG issue on ADC and get around required 16F1947 rev 2 silicon


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: SILLION BUG issue on ADC and get around required 16F1947 rev 2 silicon

    rereading the methods to get around the problem option 1 actully looks the best way , but i am not sure how to do this

    but it appears that by setting the ADC f/OSC conversion clock to the FRC internal , then putting the CPU into low power mode ( SLEEP mode ) , then doing a sample , then exit low power mode (SLEEP mode) by using the watchdog timer ( no other way i can see to make sleep mode exit)

    i am guessing this may work but not sure ,

    1. set up watchdog timer to be enabled by software bit ( _WDTE_SWDTEN ) ;WDT controlled by the SWDTEN bit in the WDTCON register) in config1 word
    2. set WDTCON with 1ms timeout and enable watchdog timer lowest time
    3. do asm command of sleep - to enter low power mode ( NAP 0 = too long a time about 18ms)
    4. do adcin command which should complete a sample in 1.6uS
    5.turn off watchdog timer

    so the assumption is that the adcin command will work in low power mode and sample will complete in a max of 1ms

    test to see !!!!!!!!!!!!

    but anyone else can advise then please do

    Cheers sheldon


    item 1
    Code:
    ' config for 16F1947
        #CONFIG
    ;----- CONFIG1 Options --------------------------------------------------
        __config _CONFIG1, _FOSC_INTOSC & _WDTE_SWDTEN & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
    
    
    ;----- CONFIG2 Options --------------------------------------------------
        __config _CONFIG2, _LVP_OFF & _BORV_HI & _STVREN_ON & _PLLEN_ON & _WRT_OFF & _VCAPEN_OFF 
        #ENDCONFIG
    item 2 - 5
    Code:
      ADCON0 =  %00010001           ' enable ADC AN4 , ADCON1 setup at start of program 
       
       y = 0                          ' ensure 0
      While Y < 10                    ' do 10 voltage reads
                                      ' silicon bug in rev2 of 16F1947 , requires ADC to be done in lowpower mode and with FDC osc clock internal
        WDTCON = %00000001            ' start watchdog timer set for 1ms so that sleep mode is exit after doing adcin commands
        asm
         SLEEP                        ;'Put cpu into low power mode  
        endasm
        ADCIN 4 ,Value                 ' Read PortA.5 value into variable , this applies the fixed voltage ref (via ADCON0,ADCON1,FVRCON)
        WDTCON = %00000000             ' stop  watchdog timer after  adcin commands
        gosub Average                  ' Go do running average of ADC reading
        y = y+1                        ' Increment loop counter
      wend

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: SILLION BUG issue on ADC and get around required 16F1947 rev 2 silicon

    That won't work, since it will have to wake from sleep before running the ADCIN command.

    I might suggest something like this...
    It doesn't work in the simulator, but hopefully it will work on real hardware.

    It uses the ADIF interrupt to wake from sleep. With the FRC clock, it only takes 48uS to complete a conversion.
    Waiting for the WDT is going to take 1000uS or more.
    The WDT is enabled just in case the conversion doesn't complete, but the ADIF should always wake it up first.

    It assumes you are using other interrupts, and disables them accordingly.
    Code:
    #CONFIG
        __config  _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_OFF & _MCLRE_ON & _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
    OSCCON = %11110000           ; 32Mhz Internal
    
    DEFINE HSER_RCSTA 90h        ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h        ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 25         ' 19200 Baud @ 32MHz, 0.16%
    DEFINE HSER_CLROERR 1        ' Clear overflow automatically
    
    ADON      VAR ADCON0.0       ; A/D converter Enable
    GoDone    VAR ADCON0.1       ; A/D conversion in progress
    ADIE      VAR PIE1.6         ; A/D Interrupt Enable
    ADIF      VAR PIR1.6         ; A/D Interrupt Flag
    GIE       VAR INTCON.7       ; Global Interrupt Enable
    GIEsave   VAR BIT            ; Saves state of GIE
    
    ADchan    VAR BYTE           ; Current A/D channel
    ADvalue   VAR WORD           ; A/D result
    
    ADCON1 = %10110000           ; Right Justify, FRC clock
    ADON = 1
    
    Main:
        FOR ADchan = 0 TO 16     ; Loop through all A/D channe
            ADCON0 = (ADCON0 & %11) | (ADchan << 2) ; Set Analog Channel
            PAUSEUS 20           ; Acquisition time
            GIEsave = GIE        ; Save state of Global Interrupts
            GIE = 0              ; Disable Global interrupts
            ADON = 0             ; reset A/D module
            ADON = 1
            ADIF = 0             ; Clear Analog Interrupt Flag
            ADIE = 1             ; Enable Analog Interrupt
            GoDone = 1           ; Start Analog conversion
            @ SLEEP              ; go to SLEEP
            ADIE = 0             ; Disable Analog Interrupt
            GIE = GIEsave        ; Restore Global Interrupt state
            ADvalue.HighByte = ADRESH  ; Get A/D result
            ADvalue.LowByte  = ADRESL
    
            HSEROUT [DEC2 ADchan," = ",DEC ADvalue,13,10]
            PAUSE 200
        NEXT ADchan
    GOTO Main
    DT

Similar Threads

  1. Possible PicBasic Pro ADC bug with 18F46k22
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd February 2012, 20:20
  2. 18F2520 ADC issue
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 24th August 2009, 16:11
  3. 32.768kHz silicon oscillator (5v)
    By bogdan in forum Schematics
    Replies: 2
    Last Post: - 6th April 2009, 00:15
  4. Battery charger - power supply issue affecting ADC
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 14th December 2008, 00:12
  5. Microchip PIC silicon Revs's
    By fbraun in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st March 2005, 15:07

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