12F683 serout timing


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2009
    Posts
    3

    Default 12F683 serout timing

    Hello all,

    I have been searching for a solution to this problem and found some answers that sounded promising but ended up not doing the trick.

    As some others have posted - I too am having trouble with the serout timing of the 12f683. I'm sending to a MAX232 and receiving with a PC running serial terminal. If I use a 16F877A it works fine, so I think the MAX is OK. Some Hex characters (below $08 and above $FC) work fine, but the ones in between are not the correct code. For instance I send $13 and the receiver gets $35. The data seems very consistent, just mostly wrong. I would prefer to not use the external resonator (behavior is the same using the internal 8MHZ clock (with OSCCON %01110000), but I wanted to try an external resonator to just to see if it would help - it did not.), but this code shows it with a external resonator.


    Code:
    Include "modedefs.bas"		' Mode definitions for Serout
    
    ' Define ADCIN parameters
    Define	ADC_BITS	8	' Set number of bits in result
    Define	ADC_CLOCK	3	' Set clock source (3=rc)
    Define	ADC_SAMPLEUS	200	' Set sampling time in uS
    
    'config_hs_osc   'do I need this?     
    define osc 8
         
    ANSEL =%00110100	' Set Internal clock, Set AN2 analog, rest digital
    CMCON0 =%00000111   'analog comparator off  
    ADCON0 =%10001001   'right justify, channel 2 analog, a/d converter on     
    OSCCON =%01111001   '8 mhz external resonator
    OSCTUNE=%00000000   'varied between %00000011 and %00011100 no help
              
    adval	var	byte		' Create adval to store result   
    
    loop:	
    
         ADCIN 2, adval		' Read channel 2 to adval
      
    	 pause 500
    	 
         serout2 GPIO.0, 396, [$13]  'receiver is seeing $35
         serout GPIO.0, T2400, [$13]  'same thing
          
    
    Goto loop		' Do it forever
    
    End
    I have seen in some of the other posts about tuning the ocillator, that doesn't seem to help. I tried varying the baud around 396 (I'm doing 2400 baud - driven true), no help.

    I think it's a timing issue, but I don't know what else to change, any ideas?

    Thanks!

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


    Did you find this post helpful? Yes | No

    Default

    Hello Hobie Cat,
    Osctune is where you tweak the OSC,
    from the data sheet below:
    OCSTUNE = 0' runs at calibrated freq.
    OSCTUNE = %00001111 ' OSC TWEAKED TO FREQ + x percent
    OSCTUNE = %00010000 ' OSC tweaked to FREQ - x percent


    Code:
    REGISTER 3-2: OSCTUNE: OSCILLATOR TUNING REGISTER
    U-0 U-0 U-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
       TUN4 TUN3 TUN2 TUN1 TUN0
    bit 7 bit 0
    Legend:
    R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
    -n = Value at POR 1 = Bit is set 0 = Bit is cleared x = Bit is unknown
    bit 7-5 Unimplemented: Read as 0
    bit 4-0 TUN<4:0>: Frequency Tuning bits
    01111 = Maximum frequency
    01110 =
    
    
    
    00001 =
    00000 = Oscillator module is running at the calibrated frequency.
    11111 =
    
    
    
    10000 = Minimum frequency
    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
    Dec 2009
    Posts
    3


    Did you find this post helpful? Yes | No

    Default osctune experience

    Thanks Joe,

    I tried varying the OSCTUNE around %00000000, it seemed to work best with no tuning, if my idea of best is right. With the tuning at 0, Hex chars below $08 and above $FC work fine it's just all the ones in between that are the wrong code, it's the same every time, just wrong. If I adjust OSCTUNE or the baud rate the characters received do change, but none of them are right, and sometimes they get jumbled, so I'm guessing that means no tuning of OSCTUNE or baud is helping.

    I'm trying to find out if there is a pattern to the wrongly received codes, like 2x or something like that. I'll let you know if I find out anything.

    Thanks!

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


    Did you find this post helpful? Yes | No

    Default

    Hello Hobie Cat,
    Make sure the idle state of the ports are correct for the communication mode you are using. TRUE data idles HIGH and requires a pull up resistor. INVERTED data idles LOW and requires a pull down resistor.
    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


    Did you find this post helpful? Yes | No

    Default have you done a search ... ?

    Hi Hobie Cat

    Just did a forum search on "12f683 serout" ..plenty results like this one
    [HTML]http://www.picbasic.co.uk/forum/showthread.php?t=12239&highlight=12f683+serout[/HTML]
    Have you maybe tried with the internal clock
    [HTML]http://www.picbasic.co.uk/forum/showthread.php?t=11824&highlight=12f683+serout[/HTML]
    and a few more tips
    [HTML]http://www.picbasic.co.uk/forum/showthread.php?t=8623&highlight=12f683+serout[/HTML]

    Hope this helps

    Dennis

  6. #6
    Join Date
    Dec 2009
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Hello Joe and Dennis,

    Thanks for the ideas. After an exhaustive day of the same results I gave up and took a nap. When I came back I tried a new chip and it works just fine.
    So, I guess somewhere I messed up some internal thing while programming maybe? The rest of the functions of the chip seem to work fine on all the ports just no correct serout on any port.

    I'm glad I bought a bunch of chips when I was doing the buying... Sorry to waste your time

  7. #7


    Did you find this post helpful? Yes | No

    Default you are not alone :-)

    Hey Hobie Cat

    Glad you solved the problem :-)

    Check my thread regarding a 16F690 ...
    I still haven't resolved my problem on that one .. I eventually decided to try a different chip so also (temporarily) just gave up on it.
    I intend to get hold of another 16F690 to eliminate whether or not it's the chip or not.

    Thanks for the info and update :-)

    Keep well
    Dennis

  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 Hobie Cat View Post
    Hello Joe and Dennis,

    Thanks for the ideas. After an exhaustive day of the same results I gave up and took a nap. When I came back I tried a new chip and it works just fine.
    So, I guess somewhere I messed up some internal thing while programming maybe? The rest of the functions of the chip seem to work fine on all the ports just no correct serout on any port.

    I'm glad I bought a bunch of chips when I was doing the buying... Sorry to waste your time
    #1. Glad you have it working, a nap's almost always a good idea.
    #2. It's never a waste of my time if you make me think. Helps keep the machinery oiled and besides, I cannot even see my bench right now, I don't want to get too rusty.
    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. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. Write to EEPROM timing, 12F683
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 31st January 2009, 23:47
  4. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  5. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26

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