16f886


Closed Thread
Results 1 to 13 of 13

Thread: 16f886

  1. #1
    Join Date
    Sep 2007
    Posts
    19

    Question 16f886

    I upgraded from 16F689 to 16F886 due to memory space. Complied fine and i am stuck with all RA's ports. I had no plm with 16F689 using RA5 as clock for shiftin command on RC.6 and RC.7. LCD commands works fine on both PICs (RC's). I cant get clock bursts out on 16F886.

    I now focus on getting RA5 or RA6 what ever on any RA's still cant all pins low. Once PIC is on, I could see all RA pins high during start up and wont get into low and cant get clockk bursts on those RA5 or RA6 since those pins stuck at high logic.

    Any idea?

    comparators are off, ADC are off. I tried everything else getting all RA's LOW.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by hvacrtech View Post
    I upgraded from 16F689 to 16F886 due to memory space......
    comparators are off, ADC are off. I tried everything else getting all RA's LOW.
    The controlling registers for the comparators and the ADC are a bit different between the '689 and the '886, different values are required in the registers themselves. So, if you're using the same code and expecting it to work, it probably won't.
    But, we'll never know without seeing some code!

  3. #3
    Join Date
    Sep 2007
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Making this LED flashing

    Here is the code,

    Similar idea as first post and still cant get LED flashing even after adding a line for device, i do get RA.6 low but still dont flash yet. without this device line, the pin stays high.



    @ INCLUDE "16F886.INC"
    Include "bs2defs.bas"

    @ DEVICE PIC16F886, INTOSCIO,WDT_ON,MCLR_OFF,LVP_OFF,PROTECT_OFF,BOD_O FF,CPD_OFF,IESO_OFF,FCMEN_OFF,PWRT_OFF 'Device line
    define osc 4
    OSCCON=%01100000
    'ANSEL=0
    'ANSELH=0
    ' ADCON1=$0F ' all digital
    'adcon0.0 = %0
    ANSEL=%00000000
    trisa= %00000000 '%00011100 used in upgrade
    'porta=%00000000
    ' ADCON0 = $00
    'cm1con0.7=0
    'cm2con0.7=0
    'CM1CON0=0 ' need it?
    'CM2CON0=0 ' need it?




    'CM1CON0 = 0
    'CM2CON0 = 0

    run:
    high 6
    pause 1000
    low 6
    pause 1000
    goto run

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    @ INCLUDE "16F886.INC"
    SHOULDN'T need this line...

    Code:
    Include "bs2defs.bas"
    @ DEVICE PIC16F886, INTOSCIO,WDT_ON,MCLR_OFF,LVP_OFF,PROTECT_OFF,BOD_OFF,CPD_OFF,IESO_OFF,FCMEN_OFF,PWRT_OFF 'Device line
    DEFINE OSC 4 <-ALL DEFINES MUST BE IN CAPS,
    'but 4Mhz is the default so it doesn't help or hurt here
    OSCCON=$60 : ANSEL=0 : ANSELH=0 : ADCON1=$0F
    adcon0=0 : trisa=0 : porta=0
    run:
    porta.6=1 : pause 1000 : porta.6=0 : pause 1000 : goto run
    END <- good practice

  5. #5
    Join Date
    Sep 2007
    Posts
    19


    Did you find this post helpful? Yes | No

    Thumbs up Port settings

    My code works. This is really interesting difference between typing in ports on 16F689 and 16F886 like 6 on 16F689 while porta.6 on 16F886 (lower cap works!) and will be sure all are Upper Cap.

    I could see the 'Scope high/low.

    I copied your code and it produce errors with OSC registery and I rem some, still producing errors.

  6. #6
    Join Date
    Sep 2007
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Mssp

    I need help on 16F886, is there config to disable MSSP?

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Here's some suggestion in case of doubt
    1. Open the datasheet under the Pin diagram section (Page 5)
    2. See what else your pin may have on (ADCs, Comparator etc etc)
    3. if so refer to each section of the extra module you want to disable, or see if they're already enable at POR

    Here you don't have anything else than MSSP Pins... so let's see section 13 and it's related Registers.

    Register 13-1: SSPSTAT
    Nothing in the list seems to enable/disable the module, let's go to the next one

    Register 13-2: SSPCON
    SSPEN bit 5
    bit 5 SSPEN: Synchronous Serial Port Enable bit
    In both modes, when enabled, these pins must be properly configured as input or output

    In SPI mode:
    1 = Enables serial port and configures SCK, SDO, SDI and SS as the source of the serial port pins
    0 = Disables serial port and configures these pins as I/O port pins

    In I2 C mode:
    1 = Enables the serial port and configures the SDA and SCL pins as the source of the serial port pins
    0 = Disables serial port and configures these pins as I/O port pins
    this bit should be =0 to disable the MSSP port, the POR values says it's already 0. Good practice to clear it yourself for safety sake, while not 100% needed.

    same for all other register.. if there's any other

    HTH
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Sep 2007
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Somehow the RA.5 randomly stays high since I use RA.5 as pulseout. Even that ADC is disabled, comparator disabled.

    Include "bs2defs.bas"
    define lcd_dreg portc
    define lcd_dbit 0 '0
    define lcd_rsreg portc
    define lcd_rsbit 4
    define lcd_ereg portc
    define lcd_ebit 5
    define lcd_bits 4
    define lcd_lines 2
    define lcd_commandus 1500 '1500 2000
    define lcd_dataus 44 '44
    PAUSE 1000
    ADCON1=$0F ' all digital
    ANSEL=%00000000

    ADCON0 = $00
    anselh = %0010 'Convert from Analog input to Digital input.
    trisb = %0010 '0=output, 1=input in analog.
    anselh = %01000000 'sets portc.6 as input
    trisc =%01000000 'sets portc.6 as input
    start:

    lcdout $FE,1,"TEST THE LCD"

    lcdout $FE,$C0," TEST"
    PAUSE 1000
    high porta.2
    pause 500
    low porta.2
    pause 500
    high portb.5
    pause 500
    low portb.5
    lcdout $FE,1,"RESETTING"
    pulsout porta.5,1000
    pause 1000
    pulsout porta.5,1000
    pause 1000
    goto start



    Above program works, but when in big program, RA.5 stays high.

    in other program, the following list is added

    ANSEL=%00100100 'Rev E
    TRISA=%00000011 'Rev E
    ADCON1 = %1
    ADCON0 = %01000101 'Rev E
    CM1CON0.7 = 0 'disables comp1
    CM2CON0.7 = 0 'disables comp2
    SSPCON.5 = 0 'disables MSSP
    'ADCON1=$0F

    and those line
    pulsout porta.5,1000


    that way randomly staying high and no longer getting pulsout. strange.

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    OK let's see what RA5 is made of...same rules apply.

    We have AN4, C2OUT and SS listed at Page 5.

    Let's refer to PORTA section, maybe we have an open collector... maybe....

    Page 47, Figure 3.6... mmm nope can be used as GP i/o.

    So let's see the ADC section, table 9-2 page 111... ANSEL register.

    This have to be
    ANSEL=0
    ADCON0=0
    Let's play safe and disable all ADCs
    ANSELH=0


    Now the comparators, Register8-1, page 90. At POR they're already disabled... but let's play safe.
    CM1CON0=0
    CM2CON0=0
    Voltage reference, register 8-5, page 99
    VRCON = 0

    Pulsout will toggle the I/O state, maybe not a bad idea to clear all I/o at the beginning.

    PORTA=0
    PORTB=0

    This ought to work. Case it doesn't, maybe not a bad idea to try
    Code:
            HIGH PORTA.5
            PAUSE whatever delay
            LOW PORTA.5
    OR add a LOW PORTA.5 after the PULSOUT line.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Sep 2007
    Posts
    19


    Did you find this post helpful? Yes | No

    Thumbs up

    Got it working partially. Will work on it tomorrow.

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Seems to work as design here using the following
    Code:
            
            @ DEVICE PIC16F886, INTOSCIO,WDT_OFF,MCLR_OFF,LVP_OFF,PROTECT_OFF,BOD_OFF,CPD_OFF,IESO_OFF,FCMEN_OFF,PWRT_OFF 'Device line
            OSCCON= %01100000
            
            Include "bs2defs.bas"
    
            DEFINE LCD_DREG PORTC 'LCD data port 
            DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4 
            DEFINE LCD_RSREG PORTC 'LCD register select port 
            DEFINE LCD_RSBIT 4 'LCD register select bit 
            DEFINE LCD_EREG PORTC 'LCD enable port 
            DEFINE LCD_EBIT 5 'LCD enable bit 
            DEFINE LCD_BITS 4 'LCD bus size 4 or 8 
            DEFINE LCD_LINES 2 'Number lines on LCD 
            DEFINE LCD_COMMANDUS 2000 'Command delay time in us 
            DEFINE LCD_DATAUS 50 'Data delay time in us 
    
            ANSEL=0
            ANSELH=0
            ADCON0=0
            CM1CON0=0
            CM2CON0=0
            VRCON = 0
            PORTA=0
            PORTB=0
            PORTC=0
            TRISA=0
            TRISB=0
            TRISC=0
            PAUSE 1000
                    
    start:
            
            lcdout $FE,1,"TEST THE LCD"
            
            lcdout $FE,$C0," TEST"
            PAUSE 1000
            high porta.2
            pause 500
            low porta.2
            pause 500
            high portb.5
            pause 500
            low portb.5
            lcdout $FE,1,"RESETTING"
            pulsout porta.5,1000
            pause 1000
            pulsout porta.5,1000
            pause 1000
            goto start
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Sep 2007
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Is CM1CON0=0 the same as CM1CON0.7 = 0?

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well yes almost...mine is the lazy writer version and clear ALL register bits, while yours clear only bit 7... which is enough anyways.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. 16f886
    By Larry in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 4th November 2008, 16:57
  2. 16f886 interrupt on portB problem
    By antonjan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th October 2008, 20:06
  3. 16F886 running out of SRAM ?
    By Chris Barron in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th August 2008, 23:01
  4. PIC Basic Pro Ver 2.47 Can't Do 16F886
    By NO2K in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th April 2008, 19:02
  5. Setting Fuses using Microcode Studio Plus
    By NO2K in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 18th May 2007, 23:14

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