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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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;-----DefineHardwaresettings' Dir SerInPort In' DIR portb in 'settaportainingressoperevitarecortocircuitiDIRportb.0in' ADC0DIRportb.1in' TASTO +DIRportb.2in' TASTO -DIRportb.4outDIRportb.5out'relais' DIR portc in'settaportainingressoperevitarecortocircuitiDIRportc.0OutDIRportc.1OutDIRportc.2OutDIRportc.3OutDIRportc.4Out;-----Constants;-----VariablesDIMadvalasbyte'variabile per ADC0Doadval=myReadADadval=adval+1loopEndfunctionmyReadADADCON0=0b00100000'Removed....'Wait AD_DelaySETGO_NOT_DONEONASMnopWaitWhileGO_NOT_DONEONSETADCON0.ADONOFFmyREADAD=ADRESendFunction
Anyone else got idea how to resolve? We have a number of chips with this banked issue.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
; ----- 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
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.
Last edit: 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
Anyone else got idea how to resolve? We have a number of chips with this banked issue.
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.
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.
Thanks for your attention and prompt reply , i will try later in this days
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
Here is the same code using BASIC instead of inline ASM: