Can anyone help at getting OWIn & OWOut to work @ 16MHz?


Closed Thread
Results 1 to 10 of 10
  1. #1
    jessey's Avatar
    jessey Guest

    Default 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
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Are you adding DEFINE OSC 16?

    If you're not, PBP defaults to 4MHz.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default 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

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I suspect you're not getting HSPLL setup/working properly. If it is, and you're defining the osc speed, then you won't need to adjust or tweak any timing.

    PBP does this for you automatically. That's the purpose of DEFINE OSC x.

    Try this with your LAB-X1 board. Set osc configuration jumper "A" to position 2-3. Remove the other two.

    Open the 18F452.INC file in your PBP directory, and change the following line.

    ;__CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H ; <-- comment out this line
    __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H ; Add this one directly below it

    Save the include file with the change.

    Now compile & run this on your X-1 board. The LED on D.0 should be blinking at 1/2S intervals.

    DEFINE OSC 16

    Main:
    HIGH PORTD.0
    PAUSE 500
    LOW PORTD.0
    PAUSE 500
    GOTO Main

    If it is, you should be ready to go.
    Last edited by Bruce; - 23rd January 2006 at 23:48.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default 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
    Attached Files Attached Files

  6. #6
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default 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

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi jessey,

    Sorry. P18F452.INC is the "Microchip" include file. Open the 18F452.INC file "in your PBP directory". Make the change to this one. Not the one located in your MPLAB directory.

    PBP has a device specific header file for each PIC it supports. These header files contain default config fuse settings for each device.

    This is the file you edit. Not the Microchip header file.

    Yes. You can make changes to over-ride config fuse settings embedded in the final .hex file with your EPIC software, however, it may not always work like you might expect.

    Example. You compile your code using the default config fuse settings in the "18F452.INC" file in your "PBP" directory. You launch the EPIC software from within MCS, and you make changes to the config fuse settings with your EPIC software.

    Now you click program, and it stil uses the default settings from the .hex file.

    What happened? If you have the "Reread file before programming", and "Update Configuration From File" options selected, it just reloads the .hex file "from disc" into memory, and dumps the default settings in.

    What most folks forget is to click the "Save" button after making changes to the config fuse settings to save them back to the .hex file on disc.

    MPASM does not like it when you have config fuse settings in your code & in the PBP 18F452.INC file. You can only have them in "1" location or it returns this error message.

    If you place the config fuse directive in your code, then you need to comment them all out in the PBP 18F452.INC header file.

    Change your Microchip P18F452.INC file back to its original state.

    Look in your "PBP" directory for 18F452.INC. Make only the change I mentioned previously, and see what you get.
    Last edited by Bruce; - 23rd January 2006 at 23:50.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default Two Versions of MBASM?

    Hello Bruce,

    I just noticed that I have 2 copies of MPASM installed on my computer. The one that MicroCode Studio makes reference to in the PicBasic Options is addressed at C:\program files\mecanique\mcsp\mpasm and the other one is located @ C:\MPASM. The one that's accessed by MicroCode Studio is version v03.50 and the other one is v03.60. I'm not sure how that happened? Both versions have the identical .inc file for the 18f452, their both Standard Header File, Version 1.4. So the one I included as an attachment in my post here is the same. The newer version has a MIGRATE.INC & a P18MACRO.INC files that the v03.50 doesn't have so that's probably the reason for the PLL not working properly. I think I remember reading a couple of years ago in the archives in a post that you can fool PBP to run faster by defining a higher osc setting than the one your using or something like that and the end result was that you had to redo all your pause settings after fooling PBP. And when I ran into that problem I didn't think about it right, I should have looked for that post to confirm.

    I guess I should delete the v03.50 and keep the v03.60 then direct MicroCode Studio to use the newer version or maybe just download and install the newest version. When I tried commenting out the code for the fuse settings it was the file at the C:\MPASM location which wouldn't have had any effect at all? I feel like an idiot. But I'm still not sure which lines to comment out because they aren't the same as the one you pointed out to me in your last post or on any other posts that I've seen so far? Maybe the newer version will have the lines you suggested to comment out. What is the newest reliable version of MPASM that available for download? I've read that some guys regret upgrading to newer versions of MPASM for reasons I'm not familiar with.

    Anyways I'll check and see if I can find the newest version and try that to see how it works out or now that I know what's going on maybe I'll try modifying the proper .inc file. I'll get back to you with my results.

    Thanks for your help
    jessey

  9. #9
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default 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

  10. #10
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default 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

Similar Threads

  1. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  2. STATUS re-curtain W
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 15:21
  3. help
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th February 2005, 20:42
  4. Need once your help one please
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th February 2005, 20:33
  5. can i slowdown owin and owout
    By Eugen in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 29th January 2005, 22:17

Members who have read this thread : 1

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