16F690 or whatever SEROUT to PC


Results 1 to 15 of 15

Threaded View

  1. #1
    xnihilo's Avatar
    xnihilo Guest

    Smile 16F690 or whatever SEROUT to PC

    Hi,

    I'd like to send an array of 70 bytes to a PC using the serial port.

    Hardware connection:

    I plan to connect PIC pin RA5 to DB9 pin 2 (RX) of the pc via an inline 1K resistor.
    (By the way, my pic pin RA5 has a 100K weak pull down because of the way I use the pin when not using it to transfer data).

    I put the following line at the top of the code:

    Code:
    Include "modedefs.bas"
    
    'Predef config at flashing time
    
    @        device  pic16F690, intrc_osc_noclkout, BOD_OFF, PWRT_OFF, wdt_off, mclr_off, protect_off
    I also use:

    Code:
    DEFINE OSC 8			'set OSC value to 8MHz for instructions PAUSE, PAUSEus and SOUND (instead of default 4MHz)
    
    DEFINE CHAR_PACING 1000
    and:

    Code:
    CLEAR
    
    INTCON = 0      'disable interrupts and clear int flags
    
    OSCCON = %01110001      'set osc to internal, HS 8MHz
    'SETTINGS  for this register:
    'bit 7: not used: 0
    'bits 6-4: IRCF bits: 8MHz internal oscillator: 111 (after a reset: auto sets to 110 = 4 MHz)
    'bit 3: OSTS bit: device is running from one of the two internal sys clocks (HFOSC or LFOSC): 0
    'bit 2: HTS bit: high freq 8MHz-125KHz status bit: shows if HFINTOSC is stable or not: 0
    'bit 1: LTS bit: low freq 31Khz status bit: shows if LFINTOSC is stable or not: 0
    'bit 0: SCS bit: sys clock selection bit: internal  oscillator is used for system clock: 1
    
    '''''''CMCON0 =  %00000111			'comparators OFF, val = 7
    
    CM1CON0.7 = 0   'disable comparator1
    CM2CON0.7 = 0   'disable comparator2
    
    ANSEL = %00000000     'choose digital i/o, val = 0
    ANSELH = %00000000	   'PIC16F690 specific		
    
    ADCON0.0 = 0            'turn adcon off (is already off by default)
    
    
    OPTION_REG = %01111111		'enable porta weak pullups (no weak pull-up available for porta.3), p12
    'bit7: pull ups are enabled by individual port latch values
    
    '-------------------------------------------------------------------------------
    TRISA = %111111 				'all porta pins are set to input (high impedance) (portA.3 is always input pin, datasheet p5), beware of floating pins
    '-------------------------------------------------------------------------------
    
    'RA5 is used in default as an input, LOW (100K ext WPD) because it waits for a +5V pulse to bring it HIGH
    
    TRISB = %0000
    
    TRISC = %00000000 				'all portc pins are set to output mode, PWM starts if CCP1CON is enabled
    
    '-------------------------------------------------------------------------------
    WPUA =  %011111 			'enable internal weak pull ups resistors individually on portA pins to bring them HIGH internaly, except for porta.3 for which the pullup is auto set if pin is enabled as MCLRE (Ra3 can be set as mclr or as i/o port with config words)
    '-------------------------------------------------------------------------------
    WPUB = %0000
    
    
    'enable for RA0-4,(RA3 has an external 10k WPU, no internal WPU is available except automaticaly if used as MCLR)
    'RA5 is LOW as default, it has an external 100k WPD (input as default).
    
    'MEMO: when pic powers up all ports are set to inputs
    
    '-------------------------------------------------------------------------------
    PORTA = %011111              'set pins logic
    '-------------------------------------------------------------------------------
    PORTB = %0000
    PORTC = %00000000 			'set pins logic
    'All are set to low by default, pins with pullups are brought automaticaly HIGH anyway
    and just before the ON INTERRUPT I have:

    Code:
        'set as output low
        TRISA.5 = 0
        PORTA.5 = 0
        FOR i = 128 to 197
            read i,hits_count    'get the number of times player was hit by this opponent
            SEROUT PORTC.5,T9600,[hits_count]
        NEXT i
        'restore as input low
        TRISA.5 = 1
        PORTA.5 = 0
    What will be output? RS232 level so I can connect it directrly to the PC or should I use MAX232 chip???

    Thanks!
    Last edited by xnihilo; - 30th May 2008 at 20:52.

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. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. 16f690 crashes
    By Lincoln S. in forum Serial
    Replies: 8
    Last Post: - 26th November 2008, 08:32
  5. Replies: 4
    Last Post: - 7th September 2005, 14:11

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