16f887 and hserin/out


Results 1 to 13 of 13

Threaded View

  1. #9


    Did you find this post helpful? Yes | No

    Default code

    Hi Joe

    Been battling with this even more now... have read up on the registers
    Still, no go JOE :-)
    Here's the code
    receiver 16f690
    Code:
    '16F690 DEMO
        DEFINE OSC 8       'Comment the 4Mhz and uncomment these for 8Mhz
        OSCCON=%01110000
    
     '   DEFINE OSC 4           'This is the default setting
     '   OSCCON=%01100000
    
    ADCON0 = 0
    ADCON1=0
        
    
    ANSEL = 0
    ANSELH = 0
    CM1CON0 = 0
    CM2CON0 = 0
    'RCSTA = %10010000 
    'txsta=%10100000
    'rcsta=%10010000
    
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $20 ' Enable transmit, BRGH = 0
    SPBRG = 25  ' 2400 Baud @ 4MHz, 0.17%
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 25  ' 2400 Baud @ 4MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    
        'The first line is if you are using PM, the second if you are using MPASAM
      '  @ device  pic16F690, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
      '  @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
            TRISA  = %00000000 'example only - TRISB = %00001111 ;Make B4-B7 outputs, B0-B3 inputs, 
            TRISB = %00100000 'TX=PORTB.7 RX=PORTB.5
            TRISC = %00000000   '0 will make the pins an output, 1 will make them inputs
      
     
       'includes begin here
            INCLUDE "modedefs.bas"
            include "c:\pbp\samples\keypad.bas"
    'end of includes
    
        TRAIN   VAR BYTE
        train =  $B3
        SYNK    VAR BYTE
        SYNK = $7E
        
        XNUM    VAR BYTE
        YNUM    VAR BYTE
        ZNUM    VAR BYTE
        LED     var PORTC.0
        
      'Variables end here
    
      loopy:
       low LED '  LED on
       
        hserin [WAIT(SYNK),XNUM,YNUM,ZNUM]
        
    ' and now out to hyperterminal (or wherever!)
        hserout["X-",DEC XNUM," Y-",DEC YNUM," Z-",DEC ZNUM,$d,$a] 'to   hyperterminal
        toggle led
        Goto loopy  ' Go back to loop and blink LED forever
        End
    'End of all code
    Transmitter is 184520 (which receiver and sends perfectly well with hserin/out) working it as the transmitter is the problem I have :-( same as for a6F690

    Code:
    'USART defines and register settings begin here     - use for HSERIN/OUT
    'Ocsillator selections here
    'DEFINE OSC 8
    'OSCCON=%01110000
    'or
    'DEFINE OSC 4
    'OSCCON=%01100000
    'OSCTUNE.6 = 0 'PLL Multiplier disabled
    'OSCTUNE.6 = 1 'PLL 4x
    'Ocsillator selections here
            OSCCON = $70            'Int CLK 8MHz
            OSCTUNE.6 = 1           'PLL 4x
            ADCON1= %00001111       '$0F = disable A/D converter
            cmcon   =   7 
            INTCON2.7 = 0     'switch pull-ups ON
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $20 ' Enable transmit, BRGH = 0
    SPBRG = 207 ' 2400 Baud @ 32MHz, 0.17%
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 207 ' 2400 Baud @ 32MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    TRISC = %10010000
    
    XNUM    VAR BYTE
            YNUM    VAR BYTE
            ZNUM    VAR BYTE
            TRAIN  VAR BYTE
            train =  $B3
            WNUM = 225
            XNUM = 31
            YNUM = 100
            ZNUM = 4
    hserin [WAIT(SYNK),XNUM,YNUM,ZNUM]
    Keep well Joe

    Kind regards
    Dennis
    Last edited by Dennis; - 19th December 2009 at 01:47.

Similar Threads

  1. HSERIN/OUT Wrong
    By Kaldurenik in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th October 2007, 10:40
  2. HSERIN/OUT or Serin/Out for AIR Link
    By mankan in forum General
    Replies: 4
    Last Post: - 25th May 2006, 15:19
  3. Hserin
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 20th March 2006, 23:09

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