Pre-Processor Settings for AS7?

Go To Last Post
27 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In Keil uVision, there's an option to change preprocessor settings under Options for Target. I cannot locate anything similar on AS7. 

Here's a section of a header file:

 

//Decode number is the number of downlink encodings based on EM4469 cfg. word encoding values.
//It is used to return the correct number in GetReaderSettings.
#define DECODE_NUMBER_MANCHESTER       1
#define DECODE_NUMBER_BIPHASE          2
#define DECODE_NUMBER_MILLER           3
#define DECODE_NUMBER_PSK2             5   //reserved
#define DECODE_NUMBER_PSK3             6   //reserved
#define DECODE_NUMBER_FSK1             8   //reserved

#define DECODE_NUMBER_LIW_CAPTURE     11
#define DECODE_NUMBER_IP_CAPTURE_6869 12
#define DECODE_NUMBER_MANCHESTER_6869 13
#define DECODE_NUMBER_4150_4026       14 
#define DECODE_NUMBER_NOT_USED        15

 

 

You may have noticed that DECODE_NUMBER_PSK2, PSK3 and FSK1 are marked as reserved. My understanding is that if I can make changes in the preprocessor settings(if any?) the demodulation schemes can be achieved (assumption).

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This has nothing to do about AS7 and everything to do with the selected target and the software framework. 

 

Please tell us something about the target and what framework, if any, you are trying to use.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
This has nothing to do about AS7

I disagree.

 

How to configure preprocessor options (specifically, command-line defines) is purely about AS7 (actually, Visual Studio) - and has nothing to do with the selected target and software framework.

 

The result of those settings, of course, will depend upon the user's code ...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

azimmali wrote:
In Keil uVision, there's an option to change preprocessor settings under Options for Target. I cannot locate anything similar on AS7. 

Go on - it's almost identical.

 

Like uVision's 'Project' window, AS has the 'Solution Explorer' - they both give you a tree view of the project structure.

 

Right-click the Project name, and choose 'Properties'

 

In the properties, choose 'Toolchain'

 

Under 'AVR/GNU C Compiler' you have:

 

  • Preprocessor
  • Symbols

 

Simples.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So where can one do this?

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Target - Atmel64 AVR MCU

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's a screenshot of the preprocessor - I havent connected the board yet to the IDE. Will it change if I do? More precise - will it show any options to change the settings?

 

 

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The node after the one you have selected above: Symbols.

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
 Symbols

Which is exactly the same name that it has in uVision!

 

Define: Check, NoExtRam, X1=1+5

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks neil. I forgot that it was called preprocessor symbols in KuV.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

Last Edited: Thu. Sep 14, 2017 - 05:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't those things really "belong" in a header file? When did we put a slew of #defines in Preprocessor symbols? Sure, maybe you CAN, but is it smart?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Thu. Sep 14, 2017 - 06:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

ka7ehk wrote:
Sure, maybe you CAN, but is it smart?

Sometimes, yes. Sometimes, no.

 

E.g. you can let symbols be defined for a specific build configuration. Hypothetical example: You are building firmware for identical devices, apart from that last years model ran at 8 MHZ and this years model runs at 16 MHz. Now you need to have F_CPU be dependent on if the build configuration is "model2016" or "model2017".

 

I know you're not a fan of using the command line/terminal, but you could look at it this way: The symbol definition in Atmel Studio is corresponding to the times you must pass a -D option on the C compiler command line to have a specific symbol defined. And in a cloaked manner you are doing this whenever you use the avr-gcc toolchain, since you explicitly (or implicitly, by picking a setting in an IDE) are passing the -mmcup option to the compiler, which in turn defines a preprocessor symbol for that model. This is how e.g. avr/io.h "knows" what part-specific header file to include.

 

A standard Atmel Studio project defined "DEBUG" for the Debug build configuration, and "NODEBUG" for the Release build configuration. You can use it e.g. to "kill" the util/delay.h functions with non-operational variants (so that you do not get caught in them while single-stepping, or if breaking, while debugging).

 

In the vast majority of cases I would prefer to define symbols in a header file because it is possible to augment that with comments forming part of the documentation. Also, header files are independent of IDE, or even toolchain (as long as we stick with standard C or C++).

 

As almost always, there is no simple b/w definitive "do" or "don't". Know the mechanism, understand what type of scenarios that needs it.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am not pretty sure of the same. #defines in the header file, directs to decoding techniques used in the main.c . The main.c unfortunately does only Manchester/BiPhase/Miller. I am not pretty sure of doing this in the preprocessor either.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan, I tried to make changes in the header file. AS is not letting me save the file.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azimmali wrote:
Johan, I tried to make changes in the header file. AS is not letting me save the file.

Trying to make changes in what header file?

 

Did you try to change one of the header files that comes with the compiler/Studio? Never do that.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not only WHAT file, but WHERE (were you trying to save it)?

 

There are a number of possible causes, ranging from (1) attempts to change standard supplied files to (2) attempting to save to a place where you do not have permissions to  (3) needing to run as administrator. 

 

I would create a new file, maybe named decode.h. I would write these defines to that file along with the standard  #ifndef .... protection statements. The file might look like this:

 

//DECODE defines for project xyz...
//September  14, 2017

#ifndef DECODE
#define DECODE

//Decode number is the number of downlink encodings based on EM4469 cfg. word encoding values.
//It is used to return the correct number in GetReaderSettings.
#define DECODE_NUMBER_MANCHESTER       1
#define DECODE_NUMBER_BIPHASE          2
#define DECODE_NUMBER_MILLER           3
#define DECODE_NUMBER_PSK2             5   //reserved
#define DECODE_NUMBER_PSK3             6   //reserved
#define DECODE_NUMBER_FSK1             8   //reserved
#define DECODE_NUMBER_LIW_CAPTURE     11
#define DECODE_NUMBER_IP_CAPTURE_6869 12
#define DECODE_NUMBER_MANCHESTER_6869 13
#define DECODE_NUMBER_4150_4026       14 
#define DECODE_NUMBER_NOT_USED        15

#endif

 

 

Then save it in the same directory as your main file. Finally, add an include statement near the start of main, as

 

#include "decode.h"

Done.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Thu. Sep 14, 2017 - 08:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim,

Thank you for the input. So this header already exists in the project. It is infact part of a header file. You may have seen //reserved for three decoding mechanisms; I am not sure if this is a preprocessor directive or a protocol/standard that has permissions or patents on its name. The hardware does not implement any of the reserved decoding schemes. We are making changes in the H/W to do so.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Those defines do nothing more than create definitions that are file-wide in scope. That is, all functions in the file that includes that header "know" what those names "mean".

 

The preprocess does not do anything more than that. It is up to you to create the code that uses those values. Probably in this case, that means to set register values in the peripheral hardware using those values. Among other things, YOU have to provide a functioning communications channel between the MCU and the peripheral chip and that channel must be properly used to move those values to their correct locations in the peripheral chip.

 

It is up to you also to provide the electrical connections to that peripheral device so that it can carry out the tasks you tell it to perform. For example, if it were a wireless chip and you tell it to transmit, that is useless unless the chip is connected to a proper antenna! If you need a decoding scheme that is not supported by the current configuration of the chip, then YOU need to change something!

 

In short, simply defining a named quantity does nothing. Using it properly is up to you.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The title of the post is, "Pre-Processor Settings for AS7?" - that question has been answered.

 

Now you're onto something completely different - which really does have nothing to do with Atmel Studio!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I totally agree with you Jim. I had previously done some preprocessor settings for LoRa (IoT) and was assuming it would be something similar. But that is not the case. I am not understanding what the code is doing anyhow.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

azimmali wrote:
You may have seen //reserved for three decoding mechanisms; I am not sure if this is a preprocessor directive 

It is a standard 'C' comment!!

// This is a comment

/* This is a comment */

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Neil, I maybe dumb but not so dumb that I cannot identify a comment in C. I mentioned that because, those decoding mechanisms are used by specific organizations under a protocol named FDX-A. I am not sure how to implement them. :D

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So what on earth did you mean by,

I am not sure if this is a preprocessor directive 

??

 

I can't see any other answer to that !

 

#define is the preprocessor directive: it simply assigns a name for string substitution - it neither knows nor cares anything about protocols or decoding mechanisms. Jim has already explained this is #18; you said you understood.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

azimmali wrote:
 I am not sure if this is a preprocessor directive 

Your 'C' text book will tell you about preprocessor directives.

 

There are only six different types of preprocessor directives

 

  1. macro definitions (#define, #undef)
  2. Conditional inclusions (#ifdef, #ifndef, #if, #endif, #else and #elif)

  3. Line control (#line)

  4. Error directive (#error)

  5. Source file inclusion (#include)

  6. Pragma directive (#pragma)

 

http://www.cplusplus.com/doc/tut...

 

 

(some compilers may add #warning - but that's about it)

 

All of this is standard & defined by the 'C' language specification - and has nothing to do with any specific application. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Neil,
Interpretation error- what I meant was that I don't know if that preprocessor directive is bound to any restrictions on the Hardware end. My bad, should have put it together properly.

Amateur programmer.
Believe when I tell you that my struggle on here is real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

You would have to examine the documentation for the hardware to determine what limitations it has.

 

Or it could just be a note that the rest of the software does not support these options.

 

Only you can determine these things as only you have access to the details of the hardware and the software.

 

None of this has anything to do with the title of this thread, or the opening question.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes sir.

Amateur programmer.
Believe when I tell you that my struggle on here is real.