config help please?


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Mar 2008
    Posts
    79

    Default config help please?

    Hi all, and before I go any further I want to say thanks to everyone who has helped me before
    The previous problem I had about trying to work a serial LCD, I've left that to one side for the moment, however for now... could anyone would be so kind as to look over my code and tell me what they see as obvious ( and not so obvious) mistakes.
    The bits I'm not sure about is the config fuses/settings. I'm going to make a seperate mini board to plug a pickit 2 into with basically a 5v psu, 18 pin socket and the pic and any other bits needed like diode, resistor etc.
    So ALL the programming will be done OFF the main board and all pins are being used as inputs or outputs only! (All digital)

    Ra2
    RA3
    RA4
    RA5 are ALL inputs (digital)

    RA1
    RA0 outputs to transistor switches
    RB6
    RB7 Outputs to LED's
    so basically all pins are outputs apart from ra2,3,4 and 5 which are inputs.

    the pic will be a 16F88
    2 X DS18B20 dq from each going to 2 seperate pins ( porta.4 and porta.5 )
    LCD 4 bit mode
    RS is on portB0
    E is PORTB1
    Data pins PORTB.2 LCD D7
    Data pins PORTB.3 LCD D6
    Data pins PORTB.4 LCD D5
    Data pins PORTB.5 LCD D4

    Really not sure about ALSO the bits parked with ****** in the code i.e. ansel adcon trisa trisb and so on, (or the config fuses) it will be using an 8Mhz ceramic resonator as thats what I've got handy
    The other thing I'm not sure about is the actual DS18B20's I dont know if I can have 2 each on a different port and address them as I have done, and IF I can,
    How do I set this? DS18B20_12bit CON %01111111 ; 750ms, 0.0625°C resolution?
    Sorry it wouldn't let me attach it as code (too big)
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    When setting the TRIS? =%????????
    0 is for output
    1 is for input

    This best explains about setting things to digital.
    http://www.picbasic.co.uk/forum/showthread.php?t=561

    And when using a resonator the config would be HS.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Think i MIGHT have that sorted now
    Code:
        CCP1CON = %00000000         ; Disable CCP Module
        SSPCON.5 = 0                ; Disable SSP Module
        TXSTA.5 = 0                 ; Disable AUSART Tx
        RCSTA.7 = 0                 ; Disable Serial Port
        CMCON =   %00000111          ; Turn off comparator
        TRISA =    %00111100
        TRISB =    %00000000
        ANSEL =   %00000000  ; Set analog ports to digital mode 
        ADCON1 = %00000111 
    
    Port B is all outputs PortA is where I MAY be going wrong, RA0 in, RA1, in,
    RA2 out, RA3out, RA4 out RA5 out 
    RA6 and RA7 clock/resonator not sure what they should be?
    Although I'm not certain about the TRISA as pins RA6 and RA7 have the resonator connected and not sure if I should have that configured there or not... but every little teaches me more

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    If memory serves me for your chip. It has an internal OSC option. When using the internal then A6 and A7 can be used for I/Os. You are using an external OSC . So your TRIS for this now will only have six bits. PINs 0 through 5.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    If memory serves me for your chip. It has an internal OSC option. When using the internal then A6 and A7 can be used for I/Os. You are using an external OSC . So your TRIS for this now will only have six bits. PINs 0 through 5.
    AHH now that makes sense.. I just wasn't sure what I should do with the pics when using them as ext OSC
    Thanks

    Apart from that, does the code look ok?
    and any ideas on how to set the higher resolution of the ds18B20 with the configuration I have?

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    From memory again. I think the USART on this chip is PORTB.2 and PORTB.5?
    And I think PORTA.5 is MCLR.
    Check the data sheet to be sure, but I think those parts are wrong in your code.
    As for the ds18B20. I can not help with this.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Changed it thanks. Hopefully it's right now.

    Anyoe know how I program it so the mclr input only works as an input pin and not mclr?
    still stuck on the ds too

    Code:
    CCP1CON = %00000000         ; Disable CCP Module
        SSPCON.5 = 0                ; Disable SSP Module
        TXSTB.5 = 0                 ; Disable AUSART Tx
        RCSTB.2 = 0                 ; Disable Serial Port
        CMCON =  %00000111          ; Turn off comparator
        TRISA =  %00111111
        TRISB =  %00000000
        ANSEL =  %00000000  ; Set analog ports to digital mode 
        ADCON1 = %00000111

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    At the same place you set the OSC for HS, either in the *.inc or in code, add this
    & _MCLRE_OFF
    You chip may not have the "E" on the end. I guess I should pull up the data sheet.

    In the MPASM directory there is anothe *.inc file that MPASM uses. Open it and near the bottom it has a listing of all the fuse settings.
    This is from that file: Nope, no "E" on this one.
    Code:
    ;==========================================================================
    ;
    ;       Configuration Bits
    ;
    ;==========================================================================
    
    _CONFIG1                    EQU     H'2007'
    _CONFIG2                    EQU     H'2008'
    
    ;Configuration Byte 1 Options
    _CP_ALL                      EQU     H'1FFF'
    _CP_OFF	                     EQU     H'3FFF'
    _CCP1_RB0		    		 EQU     H'3FFF'
    _CCP1_RB3                    EQU     H'2FFF'
    _DEBUG_OFF                   EQU     H'3FFF'
    _DEBUG_ON                    EQU     H'37FF'
    _WRT_PROTECT_OFF             EQU     H'3FFF'	;No program memory write protection
    _WRT_PROTECT_256             EQU     H'3DFF'	;First 256 program memory protected
    _WRT_PROTECT_2048            EQU     H'3BFF'	;First 2048 program memory protected
    _WRT_PROTECT_ALL             EQU     H'39FF'	;All of program memory protected
    _CPD_ON                      EQU     H'3EFF'
    _CPD_OFF                     EQU     H'3FFF'
    _LVP_ON                      EQU     H'3FFF'
    _LVP_OFF                     EQU     H'3F7F'
    _BODEN_ON                    EQU     H'3FFF'
    _BODEN_OFF                   EQU     H'3FBF'
    _MCLR_ON		   		     EQU     H'3FFF'
    _MCLR_OFF                    EQU     H'3FDF'
    _PWRTE_OFF                   EQU     H'3FFF'
    _PWRTE_ON                    EQU     H'3FF7'
    _WDT_ON                      EQU     H'3FFF'
    _WDT_OFF                     EQU     H'3FFB'
    _EXTRC_CLKOUT		    	 EQU     H'3FFF'
    _EXTRC_IO		    		 EQU     H'3FFE'
    _INTRC_CLKOUT                EQU     H'3FFD'
    _INTRC_IO		    		 EQU     H'3FFC'
    _EXTCLK			    		 EQU     H'3FEF'
    _HS_OSC                      EQU     H'3FEE'
    _XT_OSC                      EQU     H'3FED'
    _LP_OSC                      EQU     H'3FEC'
    
    ;Configuration Byte 2 Options
    _IESO_ON                     EQU     H'3FFF'
    _IESO_OFF                    EQU     H'3FFD'
    _FCMEN_ON                    EQU     H'3FFF'
    _FCMEN_OFF                   EQU     H'3FFE'
    
    
    
    ; 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_ALL).  These are currently commented out here
    ;  and each __CONFIG line should have the preceding semicolon removed when
    ;  pasted into your source code.
    
    ;Program Configuration Register 1
    ;		__CONFIG    _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC
    
    ;Program Configuration Register 2
    ;		__CONFIG    _CONFIG2, _IESO_OFF & _FCMEN_OFF
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    BTW, have you seen this thread?
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    I keep it bookmarked myself
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    No that was one I missed actually, many thanks, it's good interesting reading, Melanie must be a complete genius

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by karenhornby View Post
    No that was one I missed actually, many thanks, it's good interesting reading, Melanie must be a complete genius
    She does seem to be always correct.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by karenhornby View Post
    Melanie must be a complete genius
    That's a good word too ...
    But I'm sticking with the label she's carried for the last few years ... "Goddess"

    DT

Similar Threads

  1. Run-Time Config
    By Darrel Taylor in forum PBP Extensions
    Replies: 1
    Last Post: - 1st February 2012, 16:26
  2. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  3. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  4. Error 0X0000008E when connecting a 18F2550 USB HID
    By FranciscoMartin in forum USB
    Replies: 8
    Last Post: - 16th October 2008, 17:20
  5. Installation sequence
    By Demon in forum General
    Replies: 23
    Last Post: - 11th July 2006, 03:56

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