16F1827 setup


Closed Thread
Results 1 to 26 of 26

Thread: 16F1827 setup

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Question

    Ok ...

    1) Did you make the mods Bruce pointed at in his 6th February post ???

    you DO have to make them ...


    Also, check your PI14EEXT.BAS to make sure it has APFCON0 VAR BYTE EXT and not
    APFCON VAR BYTE EXT.

    There should also be these definitions in the PI14EEXT.BAS file;

    Code:
    MDCON VAR BYTE EXT
    MDSRC VAR BYTE EXT
    MDCARH VAR BYTE EXT
    MDCARL VAR BYTE EXT

    If these aren't in there, just add them.

    2) just Paste Bruce's code in MCS:

    Code:
    '****************************************************************
    '****************************************************************
    '*  Name    : DSM.BAS                                           *
    '*  Author  : B. Reynolds                                       *
    '*  Notice  : Copyright (c) 2010 http://www.Rentron.com         *
    '*          : All Rights Reserved                               *
    '*  Date    : 2/5/2010                                          *
    '*  Version : 1.0                                               *
    '*  Notes   : Using the 16F1827 Data Signal Modulator for IR    *
    '*          : serial communications with onboard USART.         *
    '****************************************************************
    
    ' MODOUT, RB3, outputs whatever you send with HSEROUT as a 40kHz
    ' modulated data stream. 
    
    ASM
      __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
      __config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _VCAPEN_OFF & _LVP_OFF & _STVREN_OFF
    ENDASM
    
    DEFINE OSC 8
    DEFINE HSER_BAUD 2400  
    Duty VAR WORD
    TRISB = 0
    
    Init:
      PR2 = 49             ' Set PWM for ~40kHz
      CCP1CON = %00001100  ' Mode select = PWM
      T2CON = %00000100    ' %00000100 = TMR2 ON 1:1 prescale
    
      Duty = 100           ' Roughly 50% duty cycle
      CCP1CON.4 = duty.0   ' Setup 10-bit duty cycle as
      CCP1CON.5 = duty.1   ' a 10-bit word
      CCPR1L = DUTY >> 2
      APFCON0 = 1          ' CCP1 PWM output on RB0
      OSCCON = %01110000   ' 8MHz internal
      ANSELA = 0           ' all digital. A/D disabled
      ANSELB = 0
      MDCON = %11100000    ' modulator, MODOUT pin, slew rate limiting enabled
      ' Note: set MDSRC.7 to eliminate the TX signal output on RB2/TX
      MDSRC = %00001010    ' USART TX is modulation source, TX output still active
      MDCARH = %00000000   ' carrier OFF during idle periods
      MDCARL = %00000100   ' carrier ON only when sending data
    
    Main:
      HSEROUT [$55]        ' sends USART data out modulated at 40kHz
      PAUSE 50
      GOTO Main
      END
    MUST compile without any error in MCS if 1) has been done.

    As simple as that.

    Alain
    Last edited by Acetronics2; - 19th February 2010 at 17:53.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2


    Did you find this post helpful? Yes | No

    Question

    Alain,

    I recopied the code from your post. Still getting

    Symbol not previously defined (PortC)
    Symbol not previously defined (TRISC)
    etc etc etc

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Lightbulb Bingo !!!

    Hi,

    Got it ...

    Devices affected: 16F1826, 16F1827
    Date encountered: 08/2009
    Error class: safe (always reported)

    There are invalid port aliases in the PBP header file for these parts. The following assembly errors will be generated:

    Symbol not previously defined (PORTC)
    Symbol not previously defined (TRISC)
    Workaround:

    Edit the files 16F1826.BAS and 16F1827.BAS (found in the PBP install folder) as follows:

    PORTL VAR PORTB
    PORTH VAR PORTA ' PORTC invalid, change to PORTA
    TRISL VAR TRISB
    TRISH VAR TRISA ' TRISC invalid, change to TRISA
    This is from a Melab's errata sheet Darrel Pointed at some times ago ....
    I made the mod a while ago ... so couln't see what's wrong.

    Have a nice evening

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4


    Did you find this post helpful? Yes | No

    Question

    Alain,

    Ok getting somewhere now. When I comment out all the fuse configurations between the ASM and ENDASM I get no errors. With all the mods that you suggested.

    I am down to 3 errors.

    overwriting previous address contents (8007)
    symbol not previously defined (_CAPEN_OFF)
    overwriting previous address contents (8008)

    What other files do I have to modify to get rid of these errors?

    Nick

  5. #5


    Did you find this post helpful? Yes | No

    Question

    Alain & Bruce,

    I almost resolved all the errors by modifying the files you and Bruce suggested, except for 1. I went into 16F1827.INC (PBP file) and commented out existing fuse settings and let the main code define those functions. So of the 3 remaining errors, 1 is left _VCAPEN_OFF symbol not previously defined.

    I opened up the P16F1827.INC (MPASM file) to see if there is an address for _VCAPEN_OFF....it is not listed at all...not even under Config1 or Config2.

    Wow this has been an uphill battle getting this thing to compile. Any suggestions on how to resolve this last issue would be appreciated.

    thanks,
    Nick

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


    Did you find this post helpful? Yes | No

    Default

    Just remove _VCAPEN_OFF from your config line.

    It's definitely in my P16F1827.INC file, but if Microchip has updated include files, it may
    not be in the one you have. It should work either way.
    Regards,

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

  7. #7


    Did you find this post helpful? Yes | No

    Wink

    Bruce,

    Thanks for the help. It compiled without errors. Now off to testing! I will post back my results later.

    Nick

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default Re: 16F1827 setup

    Quote Originally Posted by Bruce View Post
    It's definitely in my P16F1827.INC file, but if Microchip has updated include files, it may
    not be in the one you have. It should work either way.
    Hi Bruce.

    I searched on two MPLAB installations for this VCAPEN thing.

    It is not in my *.inc files and also it is absent from the DS41391C pdf file too.

    I wonder what is this for. Just curious.

    Ioannis

Similar Threads

  1. 16F913 setup
    By Andre_Pretorius in forum General
    Replies: 31
    Last Post: - 18th April 2010, 00:45
  2. TMR1 external LP xtal setup check
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th October 2009, 19:11
  3. ADCIN setup for PIC16F688
    By PixController in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th February 2008, 19:38
  4. ADCIN setup help need
    By dangill in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th February 2008, 16:22
  5. Use Button For setup
    By tump in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 21st November 2007, 20:43

Members who have read this thread : 2

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