PIC 18F2220 from hell


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2008
    Posts
    4

    Default PIC 18F2220 from hell

    Hello Folks,

    I am a noob when it comes to pic programin. so i am hoping to enlist the help from some of the experts of this forum. I have been having a heck of a time trying to compile a program using PBP 2.50B and MCS+ 3.0.05. I am trying to receive a serial 8N1 formated string @ 38.4K baud and output it at 9.6K baud. When i attempt tocompile i get the following errors:

    Code:
    Error[108] c:pbp\pbppic18.lib 55 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 55 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 61 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 61 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 67 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 67 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 73 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 73 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 79 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 79 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 85 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 85 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 91 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 91 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 97 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 97 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 103 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 103 : Illeagal argument
    Error[108] c:pbp\pbppic18.lib 109 : Illeagal character (=)
    Error[124] c:pbp\pbppic18.lib 109 : Illeagal argument
    I would appreciate any help and comments.

    thank you

    here is the code:

    Code:
    'Configuration Bits
    @ INCLUDE "P18F2220.INC"	 ;processor specific variable definitions
    
    @	LIST P=18F2220 ;directive to define processor and file format
    	
    
     @      __CONFIG  _CONFIG1H, _IESO_OFF_1H & _FSCM_OFF_1H & _ECIO_OSC_1H
     @     __CONFIG  _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_27_2L
     @     __CONFIG  _CONFIG2H, _WDT_OFF_2H & _WDTPS_32K_2H
     @     __CONFIG  _CONFIG3H, _MCLRE_ON_3H & _PBAD_DIG_3H & _CCP2MX_C1_3H
     @     __CONFIG  _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVR_OFF_4L
    
    ' Define Oscilator speed
    DEFINE OSC = 20
    
    RCSTA = $FAB
    TXSTA = $FAC
    SPBRG = $FAF
    
    ' Disable Analog Ports
    ADCON1 = %00001111				' Set all ports for digital operation
    
    ' Setup Imterups
    INTCON = %01000000
    
    data_ready_to_send		var	bit
    UVSSIN				var	byte
    RCTOUT 				var	byte
    
    'Use any spare port bits for flow control.
    
    flow_control_input 		var 	PORTB.4
    flow_control_output 	var 	PORTB.5
    
    ' Configure the flow-control pins as one input and one output.
    
    TRISB.4 = 1
    TRISB.5 = 0
    TRISC.6 = 0         ' Setup pin RC6 to transmit
    TRISC.7 = 1
    
    ' Assert the flow-control output to enable receiving data on the serial port.
    
    flow_control_output = 0
    
    data_ready_to_send = 0
    
    loop:
    
    ' The main program loop.
    
    gosub receive_serial_data
    gosub transmit_serial_data
    
    GOTO loop
    
    receive_serial_data:
    
    if (PIR1.5 = 1) then
    
    ' Tell the remote computer to stop sending data .
    
    flow_control_output = 1
    
    Poke SPBRG, 32
    
    ' A byte has arrived at the serial port. Read it.
    
    SERIN2 PORTC.6,32774,[RCTOUT]
    
    else
    		
    data_ready_to_send = 1
    
    endif
    return
    
    transmit_serial_data:
    
    if (data_ready_to_send = 1) then
    
    ' A byte is ready to send on the serial port.
    
    if (flow_control_input = 0) then
    
    ' The flow control input is asserted. 
    
    Poke SPBRG, 129		' Set baud rate to 9600
    
    data_ready_to_send = 0
    
     SEROUT2 PORTC.7\PORTC.4,84,[RCTOUT] 
    
    ' Tell the remote computer it's OK to send more data.	
    
    flow_control_output = 0
    
    endif
    endif
    return

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


    Did you find this post helpful? Yes | No

    Default

    Hi and welcome here.

    There's a few things you have to change and delete. Let's see
    Code:
    @ INCLUDE "P18F2220.INC"	 ;processor specific variable definitions
    @	LIST P=18F2220 ;directive to define processor and file format
    you don't need them, PBP do it for you, just delete those lines above

    Code:
    DEFINE OSC = 20
    must be written like
    Code:
    DEFINE OSC 20
    However, with this changed, you'll also need to change your OSC mode in your config fuses... and then you'll probably have a list of Error[118]... read the following thread (at least post 1 and 5)
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    Code:
    RCSTA = $FAB
    TXSTA = $FAC
    SPBRG = $FAF
    kinda hard to fit a 12bit result in a 8bit register Your program don't use the USART as it use a bit-banged solution (SERIN2/SEROUT2). If you want to use the USART, have a look in your manual for HSEROUT/HSERIN

    HTH
    Steve

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

  3. #3
    Join Date
    Oct 2008
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Hello Steve,

    Thank you for your reply. I was not sure if i need those first two lines of code. I will apply your recommendations when i get home.

    Using HSERIN, will it read data @ 38.4K assuming I DEFINE the correct BAUD and SPBRG?

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


    Did you find this post helpful? Yes | No

    Default

    Yes it will work. In fact you can change the baudrate on the fly if you need. If you do so, you'll need to change the SPBRG value.

    Have a look at my PicMultiCalc, kinda handy stuff to calculate the SPBRG register

    Download it here
    Steve

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

  5. #5
    Join Date
    Oct 2008
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Hello Steve,

    Your advice was right on. Thank you for taking the time to respond. Wihile i am fairly new to this forum, I have learned a lot from you and others who contribute to this forum regularly. The PicMultiCalc tool was very useful i will make good use of it. Thanks again.

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  4. Trouble with PIC 18F2220
    By cpayne in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 19th August 2005, 13:17
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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