Strange problem with Serin/Serout on 16F628


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    88

    Default Strange problem with Serin/Serout on 16F628

    Hello all, I have been fighting this for a few days now and I am baffled so I thought I'd toss it out to you all...

    I am trying to communicate to a serial MP3 player via a 16F268 and just can't seem to get it to go. Here is the strange part. I have no problem communicating with the player when I use a 16F876A (with a 20 mHz resonator) or a 12F629 (using the internal osc). This tell me that my circuit design is fine. I run the same code (with the appropriate device-related changes) on the different chips - 876 & 629 work - 628 doesn't. I am using pins a.0 and a.1 for the communication pins on the 628 (with CMCON = 7). Does anyone see any problems with that? I have tried running the 628 with the int osc, with a 4 mHz and a 20 mhz resonator and no difference. Here is the code:

    INCLUDE "modedefs.bas"

    @ DEVICE pic16F628, XT_OSC
    DEFINE OSC 4

    CMCON = 7

    TXPin var PORTA.0
    RXPin var PORTA.1
    Trigger var PORTB.3

    TRISA.0 = 0
    TRISA.1 = 1
    TRISB.3 = 1

    B0 var byte
    CR CON 13 ' constant value of a carriage return

    '************************************************* *******
    PAUSE 5000 'allow module time to initialize
    SEROUT txpin, T9600,["VST",CR] 'stop anything that's playing

    Loop0:
    if trigger = 1 then goto loop0 'button is pulled high via 10K resistor

    SEROUT txpin, T9600,["VPF file000.mp3",CR] 'Play a file named "file000.mp3"
    PAUSE 2000

    SERIN rxpin, T9600, [">"],B0 'Waits for "<" to indicate playing done
    PAUSE 2000
    goto loop0

    end

    Like I said above, This same code runs fine on other PICs. Is there some issue with the 628's and serial communication that I'm missing. I've been scouring through related posts and don't see anything. The way my circuit is laid out, I am kinda restricted to using A.0 and A.1 on the 628. If there is some reason I should not use those, please let me know and I'll redesign my circuit.

    Thanks!

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


    Did you find this post helpful? Yes | No

    Default

    Hi Atom058,
    I have a couple of thoughts,
    add a temporary blinky to your code to confirm PIC's operation, and check your breadboard, maybe it has some bad connections, I have had my share of headaches from that.
    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.

  3. #3
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    88


    Did you find this post helpful? Yes | No

    Default

    Joe - Thanks for your reply - On this board I have built, I have other components - a pot, an LED and a hex switch. I have been able to write snippets of code to test all of those individual items and everything works fine. The only circuitry involved with communicating with the MP3 player are 2 copper traces that go from the pic pins to the connector that the player plugs into (about 1/4" long each) - very straight forward. As I mentioned earlier, I had this working on 2 other boards that used different chips (and it still works) so it is not the player or the program. It just seems to have something to do with me using the 628. I would go back to using the 629, but I need more I/O and using the 876 is overkill. The 628 is perfect, I/O wise... I just can't figure out why it is different...

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    16F628 or 16F628A?

  5. #5
    Join Date
    Jun 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Default RB3 is also CCP1

    I don't know if this is any help but RB3 is also CCP1. There are some conditions when this may be a problem if RB3 and RB4 are both pulled low. I don't know what other pins you have connected in your circuit but it may be worth checking the CCP1CON register setting. Its also worth checking that Low Voltage Programming is disabled as this sometimes causes problems if the PGM pin is floating. Hope this isn't too far off the mark to be of some use.

    Mike

  6. #6
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    88


    Did you find this post helpful? Yes | No

    Default

    Skimask - it is a 628 - not 628A.

    Mike - I'll look into your comments and get back. Thanks!

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Atom058 View Post
    Skimask - it is a 628 - not 628A.
    Are ya sure you're compiling/assembling for the 628 and not the 628A?

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


    Did you find this post helpful? Yes | No

    Default

    I would never bet on the reliability of SEROUT @9600 baud @ 4MHz... manual says black on white that you should use higher speed crystal. Try DEBUG/DEBUGIN.

    Better if you use the INTERNAL USART with hserin/hserout...
    Steve

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

Similar Threads

  1. strange serout2 problem
    By KaanInal in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th January 2010, 09:33
  2. PIC stop responding - Strange Problem!
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 31st August 2009, 14:06
  3. strange problem 12f675
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th July 2007, 13:47
  4. Another Serin/Serout Problem!
    By jmbanales21485 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th June 2007, 16:26
  5. 16F628 on-chip eeprom problem
    By atomski in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 4th March 2004, 07:43

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