Serial com PIC <> PC - what is best?


Results 1 to 8 of 8

Threaded View

  1. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    Did you find this post helpful? Yes | No

    Default Fill PIC's program memory

    I'll try with a 4MHz crystal.

    At the end, I want to send WORDs to the PIC's program memory. I tried this internally with WRITECODE and it works as long as 4 WORDs are stored in a row.

    I can't figure out how to send more than 1 data from the terminal to the PIC. So now, I have to press "Send" a couple of times until the LCD shows up some results. I send the datas comma separated, it this so?

    Since I'm testing step-by-step, I didn't made an endless loop.

    Here is the SERIN version:
    Code:
    @ DEVICE PIC16F88,INTRC_OSC_NOCLKOUT,PROTECT_OFF,WDT_ON,PWRT_ON,MCLR_ON
    @ DEVICE PIC16F88,BOD_ON,LVP_OFF,CPD_OFF,DEBUG_OFF,CCPMX_OFF
    
    ' Register settings
    OSCCON = %01100000  'Internal RC set to 4MHZ
    ANSEL  = %00000000  'Disable Analogue Inputs
    
    ' LCDOUT command (if defaults are not changed, DEFINEs can be omitted)
    DEFINE LCD_DREG PORTB       'LCD data port 
    DEFINE LCD_DBIT 0           'LCD data starting bit 0 or 4 on µC 
    DEFINE LCD_RSREG PORTA      'LCD register select port 
    DEFINE LCD_RSBIT 3          'LCD register select bit 
    DEFINE LCD_EREG PORTA       'LCD enable port 
    DEFINE LCD_EBIT 2           'LCD enable bit 
    DEFINE LCD_BITS 4           'LCD bus size 4 or 8 
    DEFINE LCD_LINES 2          'Number lines on LCD 
    DEFINE LCD_COMMANDUS 2000   'Command delay time in us 
    DEFINE LCD_DATAUS 50        'Data delay time in us
    
    Value1   var WORD
    Value2   var WORD
    Value3   var WORD
    Value4   var WORD
    
    '-------------------------------------------------------------------------------
    ' Init LCD
    lcdout $FE, 1
    pause 1000
    
    '-------------------------------------------------------------------------------
    ' Input data from PC's terminal and show it on LCD
    serin2 PORTA.0, %100000001010100, [dec3 Value1] '9600, inverted
    serin2 PORTA.0, %100000001010100, [dec3 Value2] '9600, inverted
    serin2 PORTA.0, %100000001010100, [dec3 Value3] '9600, inverted
    serin2 PORTA.0, %100000001010100, [dec3 Value4] '9600, inverted
    lcdout dec3 Value1, " ",dec3 Value2, " ",dec3 Value3, " ",dec3 Value4
    END
    This is the HSERIN version, same problem as before:
    Code:
    @ DEVICE PIC16F88,INTRC_OSC_NOCLKOUT,PROTECT_OFF,WDT_ON,PWRT_ON,MCLR_ON
    @ DEVICE PIC16F88,BOD_ON,LVP_OFF,CPD_OFF,DEBUG_OFF,CCPMX_OFF
    
    OSCCON = %01100000  'Internal RC set to 4MHZ
    ANSEL  = %00000000  'Disable Analogue Inputs
    RCSTA  = %10010000  'Enable serial port (RB2=RX & RB5=TX) and continuous receive
    TXSTA  = %00100000  'Enable Transmit Bit
    SPBRG  = 6          'Set baudrate to 9600
    
    DEFINE LCD_DREG PORTA       'LCD data port 
    DEFINE LCD_DBIT 0           'LCD data starting bit 0 or 4 on µC 
    DEFINE LCD_RSREG PORTA      'LCD "RS" register select port 
    DEFINE LCD_RSBIT 7          'LCD "RS" register select bit 
    DEFINE LCD_EREG PORTA       'LCD "E" enable port 
    DEFINE LCD_EBIT 6           'LCD "E"  enable bit 
    DEFINE LCD_BITS 4           'LCD bus size 4 or 8 
    DEFINE LCD_LINES 2          'Number lines on LCD 
    DEFINE LCD_COMMANDUS 2000   'Command delay time in us 
    DEFINE LCD_DATAUS 50        'Data delay time in us
    
    '-------------------------------------------------------------------------------
    ' Init
    Value1 var WORD
    Value2 var WORD
    Value3 var WORD
    Value4 var WORD
    lcdout $FE, 1
    PAUSE 500
    
    '-------------------------------------------------------------------------------
    ' Input data from PC's terminal and show it on LCD
    Hserin [dec3 Value1] '9600, inverted
    Hserin [dec3 Value2] '9600, inverted
    Hserin [dec3 Value3] '9600, inverted
    Hserin [dec3 Value4] '9600, inverted
    lcdout dec3 Value1, " ",dec3 Value2, " ",dec3 Value3, " ",dec3 Value4
    END
    Attached Images Attached Images  
    Roger

Similar Threads

  1. PIC to serial with visual basic
    By mbw123 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 31st March 2007, 17:06
  2. High Speed Serial Comm PC - PIC and PIC - PIC
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 16th January 2007, 22:55
  3. Serial Communication (PC to PIC)
    By Simon Brodeur in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th January 2006, 19:55
  4. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 16:45
  5. Serial + Pic To Pic
    By chrispol in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th January 2005, 18:57

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