16F913 setup


Closed Thread
Results 1 to 32 of 32

Thread: 16F913 setup

  1. #1

    Default 16F913 setup

    I am new to the 16f913, can somebody help me with the hardware setup i want to use the first 4 pins on port a as analog inputs, the first 4 inputs on portb as digital inputs portb6 and 7 for the ICD2, the first 4 of port c as digital outputs and port c 6 and 7 for serial comunications.

    Do anyone have a way to do this setup fast on diferent micro's?

  2. #2


    Did you find this post helpful? Yes | No

    Default

    This is as far as i got, can somebody please help me with the errors mentioned below?

    DEFINE OSC 20 ' Define crystal as 20Mhz

    'This Part set PORTA 0-5 an analog inputs

    ADCON1 = %111 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
    ANSEL = 0 'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
    CMCON0= 0 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
    TRISA = %00011111 'set PORTA 0-5 as inputs


    TRISC = %10001111 'Set PORTC for serial coms and pins 0 - 3 as inputs
    TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2


    ERROR Line 13: Syntax error.
    ERROR: RAM END must be defined.
    ERROR: RAM BANKS must be defined.
    ERROR: No LIBRARY statement or LIBRARY parameter.
    ERROR: No LIBRARY statement or MACRO parameter.
    ERROR: Unable to open file PBPMAC.INC

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


    Did you find this post helpful? Yes | No

    Default

    no such error here. Which version of PBP are you using?
    Steve

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

  4. #4


    Did you find this post helpful? Yes | No

    Default

    MPLAB 8 and PBP 2.46, i also do not get the error with microstudio

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


    Did you find this post helpful? Yes | No

    Default

    mmm, sounds like a corrupted file, did you tried to re-install PBP and it's patch for 2.46?
    http://www.melabs.com/support/patches.htm
    Steve

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

  6. #6


    Did you find this post helpful? Yes | No

    Smile

    thanks, i created a totaly new project and copied my code into it, it seems to have fixed the problem it compiles now without problems.
    is there any thing you think i left out to have the pic do what i setted out to do in my first post?

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    'This Part set PORTA 0-5 an analog inputs
    
    ADCON1 = %111 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
    ANSEL = 0 'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
    CMCON0= 0 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
    TRISA = %00011111 'set PORTA 0-5 as inputs
    Nope, it disable all ADC channel <7:0>.
    http://ww1.microchip.com/downloads/e...Doc/41250F.pdf
    PDF page 45, Ansel Register.
    should be
    ANSEL = %00011111

    PDF page 183, ADCON1
    ADCON1 should be
    ADCON1=%01110000

    To disable comparators, cm<2:0> bits have to be = to 111

    so PDF page 118, CMCON0
    CMCON0=%00000111
    Last edited by mister_e; - 9th December 2007 at 21:00.
    Steve

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

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Acording to me this chould read the 0 - 5v signal on PORTA.0 and sends the digital value to hiperterminal, nothing seems to happen ,any help please
    Also i have just bought myself a ICD2 is there any special code i need to add to use the debug functions?

    DEFINE OSC 20 ' Define crystal as 20Mhz
    DEFINE HSER_BAUD 9600 ; 9600 Baud
    DEFINE HSER_CLROERR 1 ; Clear overflow automatically


    'This Part set PORTA 0-5 an analog inputs

    ADCON1 = %01110000 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
    ANSEL = %00011111 'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
    CMCON0 = %00000111 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
    TRISA = %00011111 'set PORTA 0-5 as inputs

    TRISC = %10001111 'Set PORTC for serial coms and pins 0 - 3 as inputs
    TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2

    INTCON = 0 ;Disable interrupts

    V1 var byte

    loop:
    ADCIN PORTA.0,V1
    HSEROUT [DEC V1]
    PAUSE 500
    goto loop

  9. #9
    Join Date
    Oct 2007
    Location
    Vancouver, BC, Canada
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Code:
    ADCIN PORTA.0,V1
    should it be:
    Code:
    ADCIN 0,V1
    ________________
    KV

  10. #10
    Join Date
    Oct 2007
    Location
    Vancouver, BC, Canada
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    please see this post, Brandon has the same statement as yours link >> http://www.picbasic.co.uk/forum/show...7826#post47826
    ________________
    KV

  11. #11


    Did you find this post helpful? Yes | No

    Default

    This should send out hello each 0.5 sec 9600 baud even parity instead i get 4 "Ξ" Simbols on hyper terminal, i have checked all the regesters and it seems to be ok, any body got any Suggestions??

    DEFINE OSC 20 ' Define crystal as 20Mhz

    DEFINE HSER_BAUD 9600 ; 9600 Baud
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 64h ' Enable transmit, BRGH = 1
    DEFINE HSER_BITS 9
    DEFINE HSER_EVEN 1
    DEFINE HSER_CLROERR 1 ; Clear overflow automatically

    TRISA = %00011111 'set PORTA 0-5 as inputs
    TRISC = %10001111 'Set PORTC for serial coms and pins 0 - 3 as inputs
    TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2

    INTCON = 0 ;Disable interrupts

    loop:
    HSEROUT ["Hallo"]
    PAUSE 500
    goto loop

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


    Did you find this post helpful? Yes | No

    Default

    It works here.. but i don't have the F913.. just the 917, shouldn't be the cause

    Or your Max232 circuit is wrong or you didn't set HS mode before programming your PIC.
    Steve

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

  13. #13


    Did you find this post helpful? Yes | No

    Default

    This is not the smartest of questions but i am using mplab 8 and a ICD2 and can not find were to set the HS mode, if i understand your reply correct it is a programmer option.

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


    Did you find this post helpful? Yes | No

    Default

    You have 2 choice, my favorite is to set the configuration bits in the code see the following
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    Code:
    @        __CONFIG _HS_OSC ; minimal configuration fuse setting
    or in MPLAB, click on Configure menu, then select Configuration bit
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Not with HyperTerminal!

    Code:
    DEFINE HSER_BAUD 9600 ; 9600 Baud 
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 64h ' Enable transmit, BRGH = 1
    DEFINE HSER_BITS 9
    DEFINE HSER_EVEN 1
    DEFINE HSER_CLROERR 1 ; Clear overflow automatically
    DT

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


    Did you find this post helpful? Yes | No

    Default

    I'm i allowed to not understand???? Hypercrap worked here with that setting... but... erm, i admit i've never ever dare to open the datasheet to read TXSTA settings

    Feel lazy and tired today...
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Hypercrap worked here with that setting...
    Hmmm, interesting...

    Hyperterminal doesn't have a 9-bit option.

    9-bit transmission works with 8-bit reception?
    Very interesting.

    Added: Not being sarcastic... (i know, it's a first)
    It may actually be usefull.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    hence why i've never saw any interest to use it

    I thought it would show some parity error... seems not. let me check with real software

    As stated in the manual...
    DEFINE HSER_BITS 9 'Use 9th bit for parity

    maybe i need to sleep.
    Last edited by mister_e; - 18th December 2007 at 04:48.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    maybe i need to sleep.
    You're a DJ.
    You can't sleep till after 2AM

    Still think 9/8-bit might be usefull. Not sure how though.
    <br>
    DT

  20. #20


    Did you find this post helpful? Yes | No

    Talking

    For those who are also trying this here is a working program reading the 5 analog channels on a 16F913 and sending it out on the serial port, hope this will help someone having a few less sleeples nights, thank you for everyone who helped me get this far

    INCLUDE "ANSI.INC"

    DEFINE OSC 20 ' Define crystal as 20Mhz

    '*Serial port Setup 9600 8N1*
    DEFINE HSER_BAUD 9600 ; 9600 Baud
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ; Clear overflow automatically

    '*ADC setup*
    DEFINE ADC_BITS 10 'SETS NUMBER OF BITS IN RESULTS 8,10,12
    DEFINE ADC_CLOCK 3 'SETS CLOCK SOURCE (RC = 3)
    DEFINE ADC_SAMPLEUS 50 'SETS SAMPLING TIME IN MICROSECONDS

    'This Part set PORTA 0-5 an analog inputs
    ADCON1 = %01110000 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
    ANSEL = %00011111 'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
    CMCON0 = %00000111 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
    TRISA = %00011111 'set PORTA 0-5 as inputs
    ADCON0.7 = 1 'Right justify output of ADC datasheet P145 of 16F913

    TRISC = %10001111 'Set PORTC for serial coms and pins 0 - 3 as inputs
    TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2

    INTCON = 0 ;Disable interrupts

    V1 var word
    V2 var word
    V3 var word
    V4 var word
    V5 var word


    loop:
    @ ClearScr ; Clear Screen
    ADCIN 0,V1
    ADCIN 1,V2
    ADCIN 2,V3
    ADCIN 3,V4
    ADCIN 4,V5
    HSEROUT ["Value of ADCIN 0 = ",dec V1,10,13]
    HSEROUT ["Value of ADCIN 1 = ",dec V2,10,13]
    HSEROUT ["Value of ADCIN 2 = ",dec V3,10,13]
    HSEROUT ["Value of ADCIN 3 = ",dec V4,10,13]
    HSEROUT ["Value of ADCIN 4 = ",dec V5,10,13]
    PAUSE 500
    goto loop

    END

  21. #21


    Did you find this post helpful? Yes | No

    Default Driving 2, 7-Segment LCD displays w/16F913

    Hi Mr. E and all others!

    I am new to the LCD "modules" in the 16F913 chip. I'm trying to get a basic breadboard going here using the minimum setup required to just send 2 digits to 2 displays. From there I can figure out everything else the chip needs to do. It's these damn module parameters that is screwing with my head. Specific pins to displays can be any arrangement for now.

    The App Note AN1070 and chip data leaves me confused when it comes to using PBP (v2.60) since data references are all in Assembler. Has anyone worked with this chip to arrive at a simple setup to map the pins, and how to setup the "mapping"? Do you need to create a lookup table to output the digits you want. The more I read the more I'm either missing the boat or reading too much into the minimums required to talk to the displays.

    Mega thanks, Frank

  22. #22
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    ...digits to 2 displays...????
    post the schematic please (...or lcd model # ... ext osc ?)

  23. #23


    Did you find this post helpful? Yes | No

    Default

    Here is some code I wrote for a 4 digit display and a PIC16F914. There
    is no cut and paste solution using these on chip LCD modules. Each LCD
    has different number of segments, commons and duty. The best way
    to get going is the worksheet located in the LCD section of the data
    sheet. Using the LCD data sheet you assign each segment to an LCD register. I can probably help some if you supply the LCD data sheet.

  24. #24


    Did you find this post helpful? Yes | No

    Default

    Code did not attach the first try
    Attached Files Attached Files

  25. #25


    Did you find this post helpful? Yes | No

    Default Re: 16F913... mapping done! Does this look right to you?

    Quote Originally Posted by mark_s View Post
    Here is some code I wrote for a 4 digit display and a PIC16F914. There
    is no cut and paste solution using these on chip LCD modules. Each LCD
    has different number of segments, commons and duty. The best way
    to get going is the worksheet located in the LCD section of the data
    sheet. Using the LCD data sheet you assign each segment to an LCD register. I can probably help some if you supply the LCD data sheet.
    Using the Data Sheet's pin addressing to function names, here's what I've come up with and verified "ok".

    COM-0 LCD FUNCTION ADDRESS LCD SEGMENT IC Pin
    SEG0 LCDDATA 0,0 Segment "C" 21
    SEG1 LCDDATA 0,1 Segment "D" 22
    SEG5 LCDDATA 0,5 Segment "E" 7
    SEG6 LCDDATA 0,6 Segment "DP" 14
    SEG8 LCDDATA 1,0 Segment "F" 18
    SEG9 LCDDATA 1,1 Segment "A" 17
    SEG10 LCDDATA 1,2 Segment "B" 16
    SEG11 LCDDATA 1,3 Segment "G" 15

    COM-1 LCD FUNCTION ADDRESS LCD SEGMENT IC Pin
    SEG2 LCDDATA 3,2 Segment "G" 23
    SEG3 LCDDATA 3,3 Segment "B" 24
    SEG4 LCDDATA 3,4 Segment "DP" 6
    SEG7 LCDDATA 3,7 Segment "D" 3
    SEG12 LCDDATA 4,4 Segment "E" 2
    SEG13 LCDDATA 4,5 Segment "A" 28
    SEG14 LCDDATA 4,6 Segment "F" 27
    SEG15 LCDDATA 4,7 Segment "C" 5

    Thanks, Frank

  26. #26


    Did you find this post helpful? Yes | No

    Default

    Hi Frank,
    I would need to see a schematic and have the LCD dat sheet to say for
    sure if its correct. It looks like you got the idea.

    Try blinking a segment

    Loop:
    LCDDATA0.6 = 1 'Turn on DP
    Pause 1000
    LCDDATA0.6 = 0 'Turn off DP
    Pause 1000
    Goto Loop
    Last edited by mark_s; - 16th April 2010 at 22:25.

  27. #27


    Did you find this post helpful? Yes | No

    Default Quickie question...

    Most PIC's have a "weak pull up" for the MCLR pin. On the 16F913, I don't see this is an option in any register, however, on page 220 "Configuration Bits" [CONFIG1] there is a reference to MCLR. To tie it to VDD they say to enter "0" for this binary string. Wouldn't this mean that because you'd use a "0", if not entering CONFIG1 at all, it would automatically default to "0" and apply a weak-pull up on MCLR?

    Otherwise, I would have to have a resistor/cap tied to MCLR which I really don't have the room to do if it's not absolutely necessary.

    Frank

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


    Did you find this post helpful? Yes | No

    Default

    Not sure I understand what you are after but have you
    _MCLRE_OFF
    and made the pin an input?
    Dave
    Always wear safety glasses while programming.

  29. #29
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Use meProg window

    I found that the PIC16F913 INC file didn't have all the configs listed and had to use the meProg, View, Configuration screen to set the configs from before flashing the device.

    And thanks to Mark_S for that code sample. I had finally brought the 16F913 and LCD-S401M1TF to life using about 900 Words but rewriting using your example with the LookUp table and IF/THENs reduced it to just over 500 Words.
    Last edited by LinkMTech; - 17th April 2010 at 23:31. Reason: Shout out to Mark S
    Louie

  30. #30


    Did you find this post helpful? Yes | No

    Default No compiler for the 16F913

    Hello All,

    After getting everything together for the 913, I fired up MIcroCode Studio (for those who use PicBasic Pro) just to find out that they don't support the 16F913 and above.

    How does one know how to compile from PBP to the chip?!

  31. #31


    Did you find this post helpful? Yes | No

    Default MicroCode Studio alternative?

    [QUOTE=LinkMTech;88500]I found that the PIC16F913 INC file didn't have all the configs listed and had to use the meProg, View, Configuration screen to set the configs from before flashing the device.

    How were you able to send the program to your 16F913? Are you using Microcode Studio or something else. My "chip listing" for the 16F series only goes up to 16F88 on the non-pro version 3.0.0.5 and the same for the MCS Pro version. Is there something wrong on my end or does MCS not support this 16F913 series chip. I upgraded to PBP 2.6 just because it had this chip that I have to use!

    Frank
    Last edited by PulsarProFX; - 18th April 2010 at 00:47. Reason: Not enough info to qualify the question.

  32. #32
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default MicroCode!

    I use MicroCode Studio PBP 2.47 with the MPASM compiler. It supports the 16F913 found in the drop down box.
    Louie

Similar Threads

  1. ADCIN - setup of ADCON2
    By Lowell314 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th December 2009, 19:41
  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 : 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