Menu

Warning: Current chip does not have enough common (non-banked) RAM with pic 16f526

Help
Orlando D.
2017-09-22
2017-09-27
  • Orlando D.

    Orlando D. - 2017-09-22

    I have a problem using pic 16f526, i get an insufficient memory ram warning message but if i cut "readad (an0)" it does not happen .
    What can i do to use ad conversion with this pic ?

    Thank in advance
    Orlando

    Chip 16f526

     #option explicit
         #config Osc = IOSCFS_4MHZ
    

    ; ----- Define Hardware settings
    ' Dir SerInPort In
    DIR portb in ' setta porta in ingresso per evitare cortocircuiti
    DIR portb.0 in ' ADC0
    DIR portb.1 in ' TASTO +
    DIR portb.2 in ' TASTO -
    DIR portb.4 out
    DIR portb.5 out 'relais

    DIR portc in' setta porta in ingresso per evitare cortocircuiti
    DIR portc.0 Out
    DIR portc.1 Out
    DIR portc.2 Out
    DIR portc.3 Out
    DIR portc.4 Out

    ; ----- Constants

    ; ----- Variables
    DIM adval as byte 'variabile per ADC0

    Do
    adval = Readad(AN0)
    adval =adval + 1
    loop
    End

     
  • Anobium

    Anobium - 2017-09-22

    Hello,

    Warning: Current chip does not have enough common (non-banked) RAM. This is warning and the code may operate as required however to resolve change the use of the wait or time related instructions to remove warning message.

    The NoBankRAM section in the chip data file refers to the area of microprocessor RAM that can be accessed regardless of which bank is currently selected.

    Example, the 16F59 does have RAM from 0x0A to 0x1F in bank 0, but only 0x0A to 0x0F can be accessed while another bank is selected. If for example bank 3 is selected, the PIC would be working with addresses between 0x60 and 0x7F. Accessing 0x6A to 0x6F would map back to 0x0A to 0x0F, but accessing 0x70 would access location 0x70 (not 0x10).

    This is NOT caused by the ADC code. The code for this chip, when optimised, is as below - which is not to shabby.

    ;Overloaded signature: BYTE:
    FN_READAD2
    ;***************************************
    ;Perform conversion
    ;LLReadAD 1
    ;SET ANS0 OFF
        bcf ADCON0,ANS0
    ;SET ANS1 OFF
        bcf ADCON0,ANS1
    ;SET ADCS1 OFF
        bcf ADCON0,ADCS1
    ;SET ADCS0 ON
        bsf ADCON0,ADCS0
    ;SET CHS0 OFF
        bcf ADCON0,CHS0
    ;SET CHS1 OFF
        bcf ADCON0,CHS1
    ;IF ADReadPort.0 On Then Set CHS0 On
        btfsc   ADREADPORT,0
        bsf ADCON0,CHS0
    ;IF ADReadPort.1 On Then Set CHS1 On
        btfsc   ADREADPORT,1
        bsf ADCON0,CHS1
    ;SET ADON ON
        bsf ADCON0,ADON
    ;Wait AD_Delay
        movlw   2
        movwf   SysWaitTemp10US
        call    Delay_10US
    ;SET GO_NOT_DONE ON
        bsf ADCON0,GO_NOT_DONE
    ;nop
        nop
    ;Wait While GO_NOT_DONE ON
    SysWaitLoop1
        btfsc   ADCON0,GO_NOT_DONE
        goto    SysWaitLoop1
    ;SET ADCON0.ADON OFF
        bcf ADCON0,ADON
    ;SET ANS0 OFF
        bcf ADCON0,ANS0
    ;SET ANS1 OFF
        bcf ADCON0,ANS1
    
    ;ReadAD = ADRES
        movf    ADRES,W
        movwf   READAD
        retlw   0
    
     

    Last edit: Anobium 2017-09-22
  • Anobium

    Anobium - 2017-09-22

    A method to create a HEX is to take the ASM from Great Cow BASIC and rip the code apart to remove the WAIT. I have taken the ASM above and taken to its essence removing the wait.

    This was not AD wait, you could try NOPs

    '
    #Chip 16f526
         #option explicit
             #config Osc = IOSCFS_4MHZ
    ; ----- Define Hardware settings
     ' Dir SerInPort In
    '  DIR portb in ' setta porta in ingresso per evitare cortocircuiti
      DIR portb.0 in ' ADC0
      DIR portb.1 in ' TASTO +
      DIR portb.2 in ' TASTO -
      DIR portb.4 out
      DIR portb.5 out 'relais
    
    '  DIR portc in' setta porta in ingresso per evitare cortocircuiti
      DIR portc.0 Out
      DIR portc.1 Out
      DIR portc.2 Out
      DIR portc.3 Out
      DIR portc.4 Out
    
    ; ----- Constants
    
    ; ----- Variables
      DIM adval as byte 'variabile per ADC0
    
       Do
             adval = myReadAD
    
             adval =adval + 1
        loop
       End
    
    
    function myReadAD
    
          ADCON0 = 0b00100000
    
          'Removed....
          'Wait AD_Delay
    
          SET GO_NOT_DONE ON
          ASM nop
          Wait While GO_NOT_DONE ON
          SET ADCON0.ADON OFF
          myREADAD = ADRES
    
    end Function
    

    Anyone else got idea how to resolve? We have a number of chips with this banked issue.

     
  • kent_twt4

    kent_twt4 - 2017-09-22

    Baseline 10f, 12f, 16f chips will always be difficult to manage. Using assembly is required if something more than a blinky led or basic port pin switching.

    Here is a "rough" routine to call for delay periods that could help. Put on a dvm or scope to figure out more precise delays.

    sub Delay1s (fraction255) 'i.e. 255 equals 1 sec
    
    'Option_Reg = b'11000011' 'prescale is 16
      clrf TMR0
      For Delay = 1 to fraction255  '0.998337 s
        For Delay2 = 1 to 29  '0.003915 s
          Delay3:   '129us delay
          btfss TMR0,7
          goto Delay3
          clrf TMR0
        Next
      Next
    
    end sub
    

    I remember that a very compact cycle accurate delay was made in assembly that was on Piclist or ElectrotechOnline forum. Some people have a mission to complete in least amount of program words possible.

     
  • Orlando D.

    Orlando D. - 2017-09-27

    Thanks for your attention and prompt reply , i will try later in this days

     
  • Orlando D.

    Orlando D. - 2017-10-09

    I have find this solution for ad problem on pic 16f526
    searching on pic data sheet.

    DIM adval as byte 'variable per ADC0
    movlw 69 "hex set AN#2 "01101001"
    movwf adcon0
    bsf adcon0, 1 "start conversione a/d #2
    loop0:
    btfsc adcon0, 1 "if bit1 =0 = end convers a/d else loop0
    Goto loop0
    movf adres, w "Read value in adres
    movwf adval "Save result in adval"
    'end conversion a/d

    No wait instructions because this routine wait end conversion
    bit adcon,1

     

    Last edit: Orlando D. 2017-10-09
  • William Roth

    William Roth - 2017-10-09

    Here is the same code using BASIC instead of inline ASM:

     #chip 16f526,8
     DIM ADVAL as Byte
    ADCON0 = 0b01101001
    SET ADCON0.1 ON
    Wait until ADCON0.1 = 0
    ADVAL = adres
    
    End
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.