Noise on PORTC.0 with PIC16F73


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2007
    Posts
    66

    Default Noise on PORTC.0 with PIC16F73

    Hi All

    I am using a PIC16F73 and I am trying to pulse PORTC.0, PORTC.1 and PORTC.2
    I have set these ports as outputs using TRISC = %11111000
    However, when I measure the signal on the pins, the pulse for PORTC.1 and PORTC.2 is clean, but the signal for PORTC.0 is very dirty, i.e. lots of noise?
    How can I get rid of this noise on PORTC.0?

    Thank you in advance for any help!

    Here is all my code:

    DEFINE OSC 20

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTA
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 3


    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    DEFINE NO_CLRWDT 1 ' Don't insert CLRWDTs


    TRISC = %11111000 ' Set RC0, RC1, RC2 to output, rest is input


    loop:
    PORTC.0 = 1
    PORTC.1 = 1
    PORTC.2 = 1
    PORTC.0 = 0
    PORTC.1 = 0
    PORTC.2 = 0

    Goto loop

  2. #2
    Join Date
    May 2007
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    I forgot to say:
    The noise on PORTC.0 is present during the off pulse

  3. #3
    Join Date
    May 2007
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    After reading another thread I added
    LOW PORTC.0
    just before the loop and this seemed to solve my problem!
    Why would that be?
    Isn't TRISC %11111000 supposed to set PORTC.0 as an output?

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by passion1 View Post
    After reading another thread I added
    LOW PORTC.0
    just before the loop and this seemed to solve my problem!
    Why would that be?
    Isn't TRISC %11111000 supposed to set PORTC.0 as an output?
    Hello Passion1,
    Yes TRISC <font color=red><b>=</b></font color>%11111000 will set RC0 as an output
    LOW PORTC.0 is a RMW operation and the data sheet advises not to do this on portC of this chip. RC.0 shares TMR1clockin and osc functions so you want to disable those if using as a standard I/O so:
    T1CON.0 = 0 'disable timer 1
    CCP1CON=0 ' disable capture compare module which works with timer 1
    Datasheet SEC. 4.3
    "Since the TRIS bit override is in effect while peripheral is enabled, read-modify-write instructions (BSF, BCF, XORWF) with TRISC as destination should be avoided."
    Last edited by Archangel; - 14th February 2009 at 19:23.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    May 2007
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Joe

    Thank you!
    I used

    T1CON.0 = 0 'disable timer 1
    CCP1CON=0 ' disable capture compare module which works with timer 1

    and that solved my problem completely!

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


    Did you find this post helpful? Yes | No

    Default

    I have some doubt about it... @POR, Timer1 is already off, CCP as well.

    What you experiment is indeed an RMW issue. You don't want to write to successive output bit by bit, this will cause some problem one day or another, and faster your OSC is, more chance you have to see it happen.

    What you want to do is to write to the WHOLE PORT at once instead of single bits.

    Here:
    PORTC=7
    PORTC=0
    Goto Here

    Use shadow register, modify it, then dump it to your specific PORT, that's my suggestion.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Question

    Hi, Passion

    What Kind of load do you have on portC.0 ???

    Here, your signal might not be far from ... ~ 700 kHz ( at first sight ! 555 Khz ... at second sight )

    Alain
    Last edited by Acetronics2; - 15th February 2009 at 14:22.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    I have some doubt about it... @POR, Timer1 is already off, CCP as well.

    What you experiment is indeed an RMW issue. You don't want to write to successive output bit by bit, this will cause some problem one day or another, and faster your OSC is, more chance you have to see it happen.

    What you want to do is to write to the WHOLE PORT at once instead of single bits.

    Here:
    PORTC=7
    PORTC=0
    Goto Here

    Use shadow register, modify it, then dump it to your specific PORT, that's my suggestion.
    PortC value on POR,BOR xxxx xxxx
    value on all other resets uuuu uuuu

    PortC Data direction Register
    value on all resets 1111 1111

    My theroy is T1 osc was causing his noise.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Pretty Sure a Noise Problem
    By Tobias in forum General
    Replies: 3
    Last Post: - 10th December 2009, 00:46
  2. Loud Noise at 20khz
    By koossa in forum Off Topic
    Replies: 6
    Last Post: - 14th July 2009, 09:24
  3. Need suggestions for noise suppression
    By paul.barsamian in forum General
    Replies: 2
    Last Post: - 29th March 2008, 14:37
  4. Getting rid of noise of car battery/alternator
    By passion1 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 9th March 2008, 05:11
  5. (Off Topic) Noise from battery supply
    By CLARE in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd August 2004, 10:01

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