Springe direkt zu Inhalt

C/C++ Programming

C/C++ Programming

If you haven't installed and flashed a program to your device you should first of all follow the instructions under installation in the navigation on the left side.

Assuming you have your tool chain up and running we now enter the territory of C-Programming.

Open your developing environment and the sample project that is included in the installation file. You can register processes or events that are run when the software flashed to the devices are run. Within those events and processes you can execute code that interacts with the hardware you use. Before writing code that interacts with the hardware you should consult and read exhaustively the documentation of the controller that is soldered onto the board. On the other hand you can use the firmware supported commands.

You have to decide which solution works best for you and is apropriate to your programming skills.

Firmware supported commands:

It is very important that everything you write in code returns as fast as possible. This is crucial for the ScatterWeb OS because otherwise the system can't execute it's tasks.

  • 8 KHz sample rate, 8 bit samples:
    mic Microphone (analog 8-bit samples)
    pia PIR analog (analog 8-bit samples)
    pid PIR binary (data is either 0 or 255)
    vib Vibration (data is either 0 or 255)
    lig IR intensity (data is either 0 or 255)
  • Other:
    tem Temperature. 16 bits per sample, where each sample is a 8.8 fixed point signed number (precision 8.1 bits). Sample rate 8 Hz (the DS1629 temp sensor requires 400 ms (typ) for each conversion, so there's no reason to sample faster).

 

For a very detailed description please read the ScatterWeb inside document.

manual programming on the MSB:

On the example of a MSP430 from TI

If you take a look at the controller user guide you will find many chapters inside that document. The interesting parts of this document for you is chapter 9 if you want to switch something.

Let's assume you have a LED connected to the Port 3 of the controller so you need to configure the controller that the appropriate port is configured correctly. From the processor point of view the port is an output.

Let's get in the depth. First set the direction of the port then you set the output register and then you see the LED iluinate.

  1. set the PxDIR at the correct port possition to 1. if you have the LED connected to port 3 pin 2 you write:
    P3Dir |= 0x02;
    Now the direction of this port/pin has been set to out.
  2. If you want to light the LED or give anything else power then use a Line like
    P4OUT &= ~LED;

This is very basic programing techniques but should give you an iside look of how microcontroller Programming works on those modules.