[18F4431] Trying to Set UP SPI Communication, SSPCON Register


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2007
    Posts
    3

    Default [18F4431] Trying to Set UP SPI Communication, SSPCON Register

    Hi everyone,

    I am trying to use PicBasic Pro to set up SPI communication on an 18F4431 and am having the following problem: whenever I try to set the SSPCON register (one of the control registers used by the SSP module), the compiler seems to have problems recognizing the name.

    Has anyone been able to successfully set up SPI communication using PicBasic Pro?

    Anyway, this is the code:
    SSPCON = %0011000 ;this is line 31.
    ;WCOL clear word collision indicator
    ;SSPOV overflow indicator
    ;SSP enabled
    ;idle state for clock is high
    ;SPI master mode, clock is Fosc/4.

    This is the error I get:

    Executing: "C:\PBP\PBPW.EXE" -ampasmwin -oq -z -p18F4431 "mstr.bas"
    PicBasic Pro Compiler 2.46, (c) 1998, 2005 microEngineering Labs, Inc.
    All Rights Reserved.

    C:\SPI TEST PLATFORM\MASTER\MSTR.BAS ERROR Line 31: Syntax error.Skipping link step. Not all sources built successfully.
    BUILD FAILED: Mon Jan 21 18:18:31 2008

    Regards,
    Steve

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,

    The SSPCON declaration is missing from the PIC18EXT.bas file in the PBP folder.

    You can add this line to either your main program, or the PIC18EXT.bas file.
    Code:
    SSPCON  VAR BYTE EXT
    <br>
    DT

  3. #3
    Join Date
    Nov 2007
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Hi Steve,

    The SSPCON declaration is missing from the PIC18EXT.bas file in the PBP folder.

    You can add this line to either your main program, or the PIC18EXT.bas file.
    Code:
    SSPCON  VAR BYTE EXT
    <br>
    Yep, that definitely solved it. Thanks a bunch!

    Out of curiosity, what is this PIC18EXT file? I thought all the stuff that needed to be defined was in the include file?

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The PIC??EXT.bas files are a "Bridge" between PBP and and all the registers defined by the assembler.

    Each PIC has it's own set of registers depending on what features the chip has.
    Even between chips with similar features, the registers may be at different addresses.

    In the case of the 4431, each registers address is defined in the P18F4431.INC file in the MPASM folder. And since PBP does it's compiling before MPASM gets hold of it, PBP has no idea what those addresses are.

    So it uses the PIC??EXT.bas file to define all the possible register names that might be found when using any PIC. That way they become "reserved words" that can't be accidentally used again. And more importantly, makes that name available for easy use in your program. Then at assembly time, only the names that are actually present in that chip become valid, and will have the appropriate address used for the registers.<hr>
    The 18F4431 is a bit of an odd ball.
    Most of the 18F's have an MSSP module which uses SSPCON1 and SSPCON2.

    But the 4431 has the old style SSP module. It does pretty much the same thing, but there are 2 modes that it can't operate in, that the MSSP can. And the SSP module only has the 1 SSPCON register. Hence the problem with the missing register name.

    As far as I can tell, only the 2331/2431/4331/4431 series has the old SSP.

    hth,
    DT

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  2. PIC16F877A pwm use for IR transmission
    By mcbeasleyjr in forum General
    Replies: 0
    Last Post: - 11th July 2009, 18:51
  3. Using SPI with External Interrupts
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th June 2008, 04:08
  4. 16-bit SPI problem
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th June 2008, 15:42
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

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