Using 16f676 with comms


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2005
    Posts
    67

    Talking Using 16f676 with comms

    Hi,

    Usind debug and setting the correct pins, there should be no reason that 16f676 for it to send and reeive rs232 data?

    I have setup up CMCON =7 ( comparators off)
    ANSEL = 7 (A-D 0,1,2 rest digital)
    ADCON0.7 = 1 (right justify)
    ADCON0.6 = 1 (ext vref)

    DEFINE DEBUG_REG PortC
    DEFINE DEBUG_BIT 1
    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 1

    after turnon and wait I send

    DEBUG REP $00\8,13,10,"Hello"

    but no "hello"

    any inputs?

    thnks

    Peter
    Pete

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


    Did you find this post helpful? Yes | No

    Default

    Two things...

    Firstly check the SPELLING of your DEFINES. They have to be EXACTLY right, any typo's will NOT be flagged as an error. You might also want to set PortC as all CAPS ie PORTC in the DEFINE statement.

    Finally, although it should not affect transmission, some terminal programs only display what you're sending after receiving a CR, LF... so try...

    DEBUG REP $00\8,13,10,"Hello",13,10

    You should be in business. If you haven't got a crystal or resonator as OSC to your PIC, drop down in speed as it's unlikely you'll get relaible comms at 9600 on the internal or RC oscillator.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I would suspect the PortC thing to be the source of the trouble since the DEFINE lines are case sensitive.

  4. #4
    Join Date
    Feb 2005
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Thks,

    PORTA, PORTC worked well.

    Peter
    Pete

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Good to hear Peter. Thanks for the update.

  6. #6
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Exclamation Similar Problem With Comm - Rs485

    Instead of starting a new thread , I thought of just adding my problems story to this one.

    I am have a network of RS485 using 16F676 IC. I am having a big problem with communicating with the PC.

    My harware config is :
    Pin#1 of RS485 ----> MCLR/RA3
    Pin#2&3 of RS485 --> RA4
    Pin#4 of RS485 ---> RA5

    My code is as follows:

    @ DEVICE PIC16F676,INTRC_OSC_NOCLKOUT,WDT_ON,PWRT_OFF,BOD_O N,PROTECT_OFF,CPD_OFF,MCLR_OFF
    Include "Modedefs.Bas"
    ANSEL = 0 ' DISABLE THE ANALOG INPUT
    CMCON = 7 ' DISABLE COMPARATOR ON PORTA
    VRCON = 0 ' A/D Voltage reference disabled
    TRISA = %00101000 ' SETS ALL PORTA PINS TO INPUT ' Set PORTAA to all input
    TRISC = %00000000 ' 6 Pins - LCD and 2 Pins RF Module
    LED VAR PORTC.5 ' LED (SINK)
    SER_IN VAR PORTA.3 ' DATA INPUT PORT
    DO VAR PORTA.5 ' DATA OUTPUT PORT
    RS485 VAR PORTA.4 ' RS485 CONTROL PIN
    HIGH RS485 :
    ' ----------------------------------------------------------------------
    ' ** Declare the Variables **
    I VAR WORD ' TEMP VARIABLE
    ' ----------------------------------------------------------------------
    HIGH RS485
    LOOP:

    FOR I = 16400 TO 16900 STEP 10
    SEROUT2 DO,I,["VALUE: ", DEC I,10,13] ' FOR RS232
    PAUSE 500
    NEXT

    GOTO LOOP
    END

    I seem to have lost my OSCAL value and I am trying to get a reliable comm using Hyperterminal software over RS485.

    I am getting no Output on the Hyperterminal @2400

    Can anyone help.

    regards

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


    Did you find this post helpful? Yes | No

    Default Using Async Comms? Then fit a Resonator or Xtal!

    In case anyone's missed it in a hundred or so previous threads...

    You are NEVER going to get repeatable reliable asynchronous communications at any speed without an xtal or resonator.

    You might strike lucky, or you might tear your hair out chasing your tail all because your timing is out of spec.

    I've written example code at 300 baud and posted them on this forum in great confidence only to have the code fail for someone somewhere. Async comms is just plain unreliable on internal or RC oscillators.

    I have an application which uses a 12F675 (internal Oscillator factory calibrated) which is little more than an Alarm Beeper. It's important to hit the resonant frequency of the Piezo for maximum sound. Now the Piezo is quite tollerant... it likes 4kHz, but is happy from 3.8kHz thru 4.2kHz. Out of every batch of 100 we build, there's always two or three PICs that don't make the grade with the Factory Cal. Now that's a dumb beeper application - and here you want precision async timing with a Factory OSCAL value?

  8. #8
    Join Date
    Sep 2005
    Location
    Dayton, Ohio
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    Thanks Melanie,

    You may have just saved me a few days (or weeks) of frustration. I am reading this thread only 12 hours after sending in my PCB designs for fabrication. After months of design, redesign, double-check, triple-check, I now realize I WILL need a xtal for the bootloader and PC serial comms. (I had really hoped to get away with INTOSC on the PIC18F2525 and use those I/Os for other tasks...oh well).

    LUCKILY.......I DID include the pads/traces for a xtal and caps....just in case......

    I might try the INTOSC, but only AFTER I get it working with the xtal.

    regards,
    Jim
    Jim Robertson
    "MilesTag" DIY Lasertag
    www.lasertagparts.com/mtdesign.htm
    Dayton, Ohio

  9. #9
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie
    ...I have an application which uses a 12F675 (internal Oscillator factory calibrated) which is little more than an Alarm Beeper. It's important to hit the resonant frequency of the Piezo for maximum sound. Now the Piezo is quite tollerant... it likes 4kHz, but is happy from 3.8kHz thru 4.2kHz. Out of every batch of 100 we build, there's always two or three PICs that don't make the grade with the Factory Cal. Now that's a dumb beeper application - and here you want precision async timing with a Factory OSCAL value?
    I have several 12F675's running in an NMEA application @4800 Baud on INTOSC.
    They run absolutely reliable, but to achieve this you have got to finetune OSCCAL on every single PIC.
    Accounting for the time this finetuning takes, I would never do this again.
    Today I do not even use resonators on applications where serial comms are involved,
    all my never designs include a crystal and two caps.
    At the end this is the less expensive solution since it doesn't require any calibration.
    Last edited by NavMicroSystems; - 28th October 2005 at 19:18.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  10. #10
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Need to redesign !

    Thank you folks. I guess , I have to redesign the board using 16F72 IC.

    Hence forth I shall always remember to use a Xtal where necessary.

    regards

    Charudatt

Similar Threads

  1. 16F676 programming problem
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th May 2009, 17:39
  2. PIC12F675 comms issues
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th March 2007, 04:24
  3. Remote comms
    By thirsty in forum Serial
    Replies: 1
    Last Post: - 23rd June 2006, 15:42
  4. Pic to Pc Comms
    By Darrenmac in forum General
    Replies: 2
    Last Post: - 21st May 2005, 01:44
  5. USB comms
    By rastan in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th March 2005, 17:14

Members who have read this thread : 0

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