Preprocessor woes


Yesterday 23:03
Forum: Proton Plus Compiler v3
Starter: gdesantis
Views: 0
Replies: 3
Yesterday 20:28
Forum: PICKit Plus
Starter: evan
Views: 0
Replies: 7
+ Reply to Thread
Results 1 to 3 of 3

Thread: Preprocessor woes242 days old

  1. #1
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,853
    Thumbs Up
    Received: 163
    Given: 162
    Total Downloaded
    3.24 GB

    0 Not allowed!

    Default Preprocessor woes

    In a previous thread here about $if Les posted

    That's because the $define now equals "19200 Then" and not just "19200", so it will always be false.

    $defines work purely on text.
    As a 16F690 has 1 USART, _usart should and appearently is 1. Why isn't the preprocessor error generated?

    Code:
      Device = 16F690
    
      $define D_HardSerialNum 2
        
      $if D_HardSerialNum > _usart
        $error "Incorrect setting for D_HardSerialNum - nonexistant USART" 
      $endif
    Am I comparing the text "2" with the text "_usart"? if so then thats weird cause I use comparisons like that that produce correct results. eg $if _xtal = 48
    Last edited by towlerg; 15th April 2018 at 16:13.
    George

  2. #2
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,019
    Thumbs Up
    Received: 312
    Given: 120
    Total Downloaded
    1.51 GB

    0 Not allowed!

    Default Re: Preprocessor woes

    The preprocessor has the $define _uart 1, so the code below works as expected:

    Code:
        Device = 16F690
    
      $define D_HardSerialNum 2
        
      $if D_HardSerialNum > _uart
        $error "Incorrect setting for D_HardSerialNum - nonexistant USART" 
      $endif
    I'll change the .def files so that both _usart and _uart are assigned, because MIcrocohip changed their mind about the peripheral's name. It was, and still is, a UART, but is now designated a USART! I'll also add it to the manual, and change the IDE's mcp file to match.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  3. #3
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,853
    Thumbs Up
    Received: 163
    Given: 162
    Total Downloaded
    3.24 GB

    1 Not allowed!

    Default Re: Preprocessor woes

  4. Thanks Les, how foolish of me though, I looked in the def file but didn't see the difference in the spelling.
    George

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Bootloader woes
    By towlerg in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 24th June 2016, 18:20
  2. HRSIN woes !
    By C_Moore in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 3rd August 2008, 16:35
  3. RS232 Woes
    By Whitt in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 19th October 2006, 19:06
  4. Bootloader woes
    By ScottBridges in forum Mecanique - IDE
    Replies: 3
    Last Post: 26th January 2006, 15:37

Members who have read this thread : 39

Actions :  (Set Date)

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts