1 Attachment(s)
Can anyone help at getting OWIn & OWOut to work @ 16MHz?
Hello Everyone,
I've been playing with the H4 (HSPLL) feature on my 18f452 and the better part of my program seems to work quite well after I adjusted my pauses. I have a program that I wrote around a Lab-x1 program called onewire.bas that uses the OWIn & OWOut commands to read a DS1820 temp sensor. It works great at 4MHz but after selecting the PPL feature and running it at 16MHz I can't seem to figure out how to get it working again. Would anyone know what I'd have to do to get it working properly at 16MHz?
I copied and pasted the example program called tempx.bas from Micro Engineering's web site and it works great to read and display the DS1820 running at 16MHz after I adjusted the pauses in that program but I can't seem to figure out anything for the onewire.bas program.
Would anyone have any suggestions on what I could try to get the onewire.bas program working at 16MHz? I've included the basic program below if that would help. I'm using PBP ver 2.45 with MicroCode Studio 2.1.0.7 and MPASM v03.60 and the EPIC ver 2.46 beta programmer.
Thanks
jessey
Yes it's there, DEFINE OSC 16
Hi Bruce,
Yes I have defined the osc at 16MHz. This is my first attempt at trying the 4xPLL option and as far as I can tell that part seems to be working ok. I noticed that I had to divide my pause statements by 4 in order to get the expected pause times that I had when running @ 4MHz.
Thanks
jessey
1 Attachment(s)
Could it be my beta upgrade for my EPIC programmer?
Thanks Bruce,
Shows you what I know LOL, I didn't realize that. I'm just a hobbyist here and have a lot to learn. I checked the archives before attempting to use the PLL and didn't find any info about the pause statements being handled in PBP. I did find discussions on the configuration settings which varies (from what I could tell) on whatever version of MPASM is used. I didn't see any discussions on the specific one I have which is v03.60. Maybe I don't have the configuration fuses set up properly but I thought I could just set them with my EPIC programmer?
Most of the discussions I read stated to either edit the inc file for the chip or comment out the ones you want to set in code in the inc file and then use @ to set them. My inc file included a section that could be copied and pasted into your code to set-up the fuses and it didn't say anything about commenting out any sections to use them. This is what it had to say in the inc file for the 18f452:
; To use the Configuration Bits, place the following lines in your source code
; in the following format, and change the configuration value to the desired
; setting (such as CP_OFF to CP_ON). These are currently commented out here
; and each __CONFIG line should have the preceding semicolon removed when
; pasted into your source code.
I tried cutting and pasting them into my program (11 in all) and they all worked except for these two:
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _RCIO_OSC_1H
@ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
And according to what I read in the archives, I should be using this one:
@ __CONFIG _CONFIG1H, _OSCS_ON_1H & _HSPLL_OSC_1H
But I should be able to use the EPIC to select the fuse settings as well although it would be great if I could set them all in code, of which I can do for 9 of them but not for the one I really need. When I tried to compile the one below I got two errors:
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
Error[118]c:\ds1820 9.asm 276 Overwriting previous address contents (0000)
Error[118]c:\ds1820 9.asm 276 Overwriting previous address contents (0001)
I tried commenting out lines in the inc file that were related to the above CONFIG1H but no success. I did make a backup copy of the inc file before I started playing with it and have it in an attachment below if you'd like to have a look.
Another thing, when I upgraded my EPIC to be able to programme the 18F's I opted to use the free beta version. It stated that it had some limitations imposed but didn't elaborate as to what those limitations were. Maybe? The upgrade was only $10.00 USD but it was easier to just download and install the free beta version and not have to wait for the postman or courier. Do you think that could be part of my problem?
Thanks
jessey
Here are the fuse settings that I copied & pasted into my program
Hi Bruce,
I'm not using my Labx experimenters board for this one, I have it bread boarded. One more thing I noticed is that when I first copied and pasted the code from my inc file into my program is that only 7 of them would compile. Then I started moving them around and when I placed the CONFIG2H statement above the CONFIG2L statement then they both compiled....... strange? This is what I pasted into my code below to configure my fuse settings:
'@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _RCIO_OSC_1H; This dosen't compile
;Configuration Byte 1H Options
'_OSCS_ON_1H EQU H'DF' ; Oscillator Switch enable
'_OSCS_OFF_1H EQU H'FF'
'_LP_OSC_1H EQU H'F8' ; Oscillator type
'_XT_OSC_1H EQU H'F9'
'_HS_OSC_1H EQU H'FA'
'_RC_OSC_1H EQU H'FB'
'_EC_OSC_1H EQU H'FC' ; External Clock w/OSC2 output divide by 4
'_ECIO_OSC_1H EQU H'FD' ; w/OSC2 as an IO pin (RA6)
'_HSPLL_OSC_1H EQU H'FE' ; HS PLL
'_RCIO_OSC_1H EQU H'FF' ; RC w/OSC2 as an IO pin (RA6)
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H; this one was below 2L code
;Configuration Byte 2H Options
'_WDT_ON_2H EQU H'FF' ; Watch Dog Timer enable
'_WDT_OFF_2H EQU H'FE'
'_WDTPS_128_2H EQU H'FF' ; Watch Dog Timer PostScaler count
'_WDTPS_64_2H EQU H'FD'
'_WDTPS_32_2H EQU H'FB'
'_WDTPS_16_2H EQU H'F9'
'_WDTPS_8_2H EQU H'F7'
'_WDTPS_4_2H EQU H'F5'
'_WDTPS_2_2H EQU H'F3'
'_WDTPS_1_2H EQU H'F1'
' was ON was OFF
@ __CONFIG _CONFIG2L, _BOR_OFF_2L & _BORV_20_2L & _PWRT_ON_2L
;Configuration Byte 2L Options
'_BOR_ON_2L EQU H'FF' ; Brown-Out Reset enable
'_BOR_OFF_2L EQU H'FD'
'_PWRT_OFF_2L EQU H'FF' ; Power-Up Timer enable
'_PWRT_ON_2L EQU H'FE'
'_BORV_20_2L EQU H'FF' ; BOR Voltage - 2.0v
'_BORV_27_2L EQU H'FB' ; 2.7v
'_BORV_42_2L EQU H'F7' ; 4.2v
'_BORV_45_2L EQU H'F3' ; 4.5v
'@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H; This dosen't compile here
';Configuration Byte 2H Options but compiles above 2L
''_WDT_ON_2H EQU H'FF' ; Watch Dog Timer enable
''_WDT_OFF_2H EQU H'FE'
''_WDTPS_128_2H EQU H'FF' ; Watch Dog Timer PostScaler count
''_WDTPS_64_2H EQU H'FD'
''_WDTPS_32_2H EQU H'FB'
''_WDTPS_16_2H EQU H'F9'
''_WDTPS_8_2H EQU H'F7'
''_WDTPS_4_2H EQU H'F5'
''_WDTPS_2_2H EQU H'F3'
''_WDTPS_1_2H EQU H'F1'
' was ON
@ __CONFIG _CONFIG3H, _CCP2MX_OFF_3H
;Configuration Byte 3H Options
'_CCP2MX_ON_3H EQU H'FF' ; CCP2 pin Mux enable
'_CCP2MX_OFF_3H EQU H'FE'
'' This dosen't compile below
'@ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
';Configuration Byte 4L Options
''_STVR_ON_4L EQU H'FF' ; Stack over/underflow Reset enable
''_STVR_OFF_4L EQU H'FE'
''_LVP_ON_4L EQU H'FF' ; Low-voltage ICSP enable
''_LVP_OFF_4L EQU H'FB'
''_DEBUG_ON_4L EQU H'7F' ; Backgound Debugger enable
''_DEBUG_OFF_4L EQU H'FF'
@ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
;Configuration Byte 5L Options
'_CP0_ON_5L EQU H'FE' ; Code protect user block enable
'_CP0_OFF_5L EQU H'FF'
'_CP1_ON_5L EQU H'FD'
'_CP1_OFF_5L EQU H'FF'
'_CP2_ON_5L EQU H'FB'
'_CP2_OFF_5L EQU H'FF'
'_CP3_ON_5L EQU H'F7'
'_CP3_OFF_5L EQU H'FF'
' was ON
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
;Configuration Byte 5H Options
'_CPB_ON_5H EQU H'BF' ; Code protect boot block enable
'_CPB_OFF_5H EQU H'FF'
'_CPD_ON_5H EQU H'7F' ; Code protect Data EE enable
'_CPD_OFF_5H EQU H'FF'
@ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
;Configuration Byte 6L Options
'_WRT0_ON_6L EQU H'FE' ; Write protect user block enable
'_WRT0_OFF_6L EQU H'FF'
'_WRT1_ON_6L EQU H'FD'
'_WRT1_OFF_6L EQU H'FF'
'_WRT2_ON_6L EQU H'FB'
'_WRT2_OFF_6L EQU H'FF'
'_WRT3_ON_6L EQU H'F7'
'_WRT3_OFF_6L EQU H'FF'
@ __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
;Configuration Byte 6H Options
'_WRTC_ON_6H EQU H'DF' ; Write protect CONFIG regs enable
'_WRTC_OFF_6H EQU H'FF'
'_WRTB_ON_6H EQU H'BF' ; Write protect boot block enable
'_WRTB_OFF_6H EQU H'FF'
'_WRTD_ON_6H EQU H'7F' ; Write protect Data EE enable
'_WRTD_OFF_6H EQU H'FF'
@ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
;Configuration Byte 7L Options
'_EBTR0_ON_7L EQU H'FE' ; Table Read protect user block enable
'_EBTR0_OFF_7L EQU H'FF'
'_EBTR1_ON_7L EQU H'FD'
'_EBTR1_OFF_7L EQU H'FF'
'_EBTR2_ON_7L EQU H'FB'
'_EBTR2_OFF_7L EQU H'FF'
'_EBTR3_ON_7L EQU H'F7'
'_EBTR3_OFF_7L EQU H'FF'
@ __CONFIG _CONFIG7H, _EBTRB_OFF_7H
;Configuration Byte 7H Options
'_EBTRB_ON_7H EQU H'BF' ; Table Read protect boot block enable
'_EBTRB_OFF_7H EQU H'FF'
And with the two CONFIG1H & CONFIG4L sections commented out, it compiles ok and I can use them.
Thanks
jessey
I'm sure I'll get it now..........Thanks
Many Thanks Bruce,
We seem to be playing tag here but after reading your last post I found the proper .inc file in PBP, thanks for the clarifation. Cool.............
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F452, r = dec, w = -311, f = inhx32
INCLUDE "P18F452.INC" ; MPASM Header
__CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG4L, _LVP_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8
And these are the 3 that I couldn't get to compile. It makes perfect sense now. Live and learn!! This list is great............
Many Thanks Again
jessey
Everything is working good now, thanks for your help.
Hello Bruce,
It worked like a charm. I commented out all 3 lines in the 18F452.INC file in PBP and now have all 11 of the @ __CONFIG fuse settings compiled into my program and have total control over all the settings within the program I'm writing. Now I can just cut and paste them into any future programs. And also, now my pause statements have the correct timing too so everything is working just great. Thanks again!
Thanks
jessey