Hardware

(So far Xduino v0.31 has only been tested on board with STM32F10ret6 mcu.)

  • Command reference
  • Extended reference
    • Serial ports
    • Serial port buffering
    • Math library
    • Standard library
    • Other library
    • Analog ports
    • Analog input channels
    • Analog output channels
    • Interrupt note
    •  

      Command reference:

      Pin mode

      pinMode(PIN, orthopedist MODE);
      Set the specified PIN to MODE
      MODE can be

      • INPUT for receiving digital input
      • OUTPUT for sending digital output
      • ANALOGIN for receiving analog input
      • ANALOGIN for sending analog output

      ANALOGOUT for sending analog output
      (not that not every PIN has analog functionality, please refer to PIN definition table below)
      example:

      pinMode(PB1,INPUT);

      Digital input/output

      digitalWrite(PIN,DATA);
      Send digtal DATA output to PIN. DATA can be either HIGH or LOW
      example:

      pinMode(PB2,OUTPUT);
      digitalWrite(PB2,HIGH);

      digitalRead(PIN);
      Read digital input from PIN. The result can be either HIGH or LOW.
      example:

      bool PB1state;

      pinMode(PB1,INPUT);
      PB1state=digitalRead(PB1);
      if(PB1state==HIGH)
      {
      Serial1.println(“PB1 state is high”);
      } else {
      Serial1.println(“PB1 state is low”);
      }

      digitalToggle(PIN);
      Toggle the digital state of PIN. If PIN is high then change PIN state to LOW.
      If PIN is low then change state to HIGH.
      example:

      pinMode(PB2,OUTPUT);
      digitalWrite(PB2,HIGH);
      delay_mS(1000); // pause for 1000 milliseconds
      digitalToggle(PB2);

      Analog input (ADC)

      analogRead(ADC_CHANNEL);

      Read analog input, the output value is between 0-4095 representing 0-3.3V.
      To find out which pin cirresponds to ADC_CHANNEL number please check the PIN definition at the Analog input channels table below

      int AnalogData;
      pinMode(PB0, ANALOGIN);
      AnalogData=analogRead(1);
      Serial1.printf(“Analog channel 1 (PB0) input is %d”,AnalogData);

      Analog output (DAC)

      analogWrite(DAC_CHANNEL,DATA);
      Output DATA to the specified Analog DAC_CHANNEL. The output value must
      be between 0-4095 representing 0-3.3V. To find out which pin corresponds to DAC_CHANNEL number
      check the PIN definition of the Analog output channels table below.

      analogWrite(1,0); // no voltage to DAC channel 1
      delay(1000); // wait 1000 milliseconds
      analogWrite(1,2047); // half of the full voltage
      delay(1000); // wait 1000 milliseconds
      analogWrite(1,4095); //full voltage output

      analogLastWrite(DAC_CHANNEL);
      Get the data value used by previous analogWrite command on the DAC_CHANNEL number.

      int lastDACvalue;
      lastDACvalue=analogLastWrite(1); // get the value from DAC channel 1

      Interrupt setting

      attachInterrupt(PIN,FUNCTION_NAME,INTERRUPT_MODE);
      Activate the specified FUNCTION_NAME when PIN gets into INTERRUPT_MODE.
      FUNCTION_NAME is the function which has to be declared in the main program.
      INTERRUPT_MODE can be

      • RISING for activating when the PIN changes state from LOW to HIGH only
      • FALLING for activating when the PIN changes state from HIGH to LOW only
      • CHANGE for activating when PIN changes state both from HIGH to LOW and from LOW to HIGH.
      • (Important: read the Interrupt note to understand interrupt channel selection.)

        Example :
        To create a light blink an led connected to PA15 when PB8 changes state from LOW to HIGH

        int LEDpin=PA15

        void BlinkLed(void)
        {
        Serial1.println(“Interrupt activated”);
        digitalWrite(LEDpin,HIGH);
        pause(1000); // must use pause instead of delay in interrupt function
        digitalWrite(LEDpin,LOW);
        }

        int main()
        {
        doInit();
        Serial1.begin(115200);

        attachInterrupt(PB8,BlinkLed,RISING);
        }

        detachInterrupt(PIN);
        Deactivate Interrupt assigned on PIN

        Example:

        detachInterrupt(PB8);

        interrupts();
        Enable all interrupts that has been assigned by attachInterrupt command
        This is generally used after noInterrupts command to reactive the interrupts.

        Example:

        interrupts();

        noInterrupts(void);
        Deactivate all interrupts assigned by attacheInterrupt command.

        Example:

        noInterrupts();

        // simple SPI functionality emulation output only, without latch
        shiftOut(u8 PxnDataOut,u8 PxnClock,bool BitOrder,u8 Data);
        (explanation coming soon)

        // simple function to retrieve time when Pxn changes state
        pulseIn(u8 Pxn,bool startState,u32 TimeOut=0);
        (explanation coming soon)

        Timing

        millis(void);
        Return the number of milliseconds since the program execution started.

        Example:

        Serial1.printf(“This has been running for %lu milliseconds.
        “,millis());

        micros();
        Return the number of microseconds since the program execution started.

        Example:

        Serial1.printf(“This has been running for %lu microseconds.
        “,micros());

        delay(MILLISECONDS);
        Stop program execution for MILLISECONDS.
        Note: this cannot be used within interrupt functions

        Example:

        delay(1000); // stop for 1000 milliseconds which is equal to 1 second

        delayMicroseconds(MICROSECONDS);
        Stop program execution for MICROSECONDS.
        Note: this cannot be used within interrupt functions

        Example:

        delayMicroseconds(10000); // stop for 10000 microseconds which is equal to 10 milliseconds

        pause(MILLISECONDS);
        Stop program execution for ‘approximately’ MILLISECONDS.
        This can be used in interrupt functions.
        Note: the delay is only an approximation

        Example:

        pause(1000);

        pauseMicroseconds(MICROSECONDS);Stop program execution for ‘approximately’ MICROSECONDS.
        This can be used in interrupt functions.
        Note: the delay is only an approximation

        Example:

        pauseMicroseconds(10000);

        Random number

        randomSeed(SEED);
        Choose SEED to be seed of the random number in the program.
        SEED must be a number.
        To allow the program to ‘attempt’ to randomize the seed put nothing as the SEED.

        Example:
        To allow program to ‘attempt’ to randomize the seed autmatically

        randomSeed();

        To specify a random seed

        randomSeed(1234);

        random(MAX);
        Generate a random number between 0 and MAX-1

        Example:

        int myNumber;
        myNumber=random(1000); // get a number between 0 and 999

        random(MIN,MAX);
        Generate a random number between MIN and MAX-1

        Example:

        int myNumber;
        myNumber=random(1000,2000); // get a number between 1000 and 1999

        Extended reference

        There are a few things to keep in mind when using Xduino v0.3
        Major Features:
        All Arduino syntax are compatible with Xduino v0.31 (as per Arduino references and Arduino extended references page except for analogReference() command.)

        Serial ports
        There are total of 5 serial ports so Serial1-5 commands can be used.
        There is also a special serial port output command ‘printf’ this function can be used like the general C/C++ printf function with up to 5 parameters on the Serial command like

        Serial1.printf(“Xduino v%f
        “,0.3);
        Serial1.printf(“Parameter: %d %d %d %d %d
        “,1,2,3,4,5); // maximum 5 parameters

        Serial port buffer
        Now all Serial ports supports seperate buffering for Rx and Tx. This enables the buffer size to be specified individually for each Serial port. Buffer can be disabled by setting the buffer size to 0.
        This example shows how to set the Serial1 port Rx buffer size to 128bytes and disables the Tx buffering.

        Serial1.RxBufferSize=128;
        Serial1.TxBufferSize=0;
        Serial1.begin(115200);

        (Note: Buffer size setting must be before Serialx.begin() call)

        Math library (math.h)
        Mathematical functions are included. For full information please check this math.h page.

        Standard library (stdlib.h)
        Standard library functions are available. For full information please check this stdlib.h page.

        Other C or C++ library
        Other C and C++ libraries can also be included, extending the limitation of functionality.

        Analog ports
        All Analog input and Analog output channels have 12-bits data. This means that when reading analog channel by using analogRead() command the returned value is between 0 and 4095 and when writing to analog output channel one can write value 0 and 4095.

        Analog input channels (ADC)
        There are total of 15 analog input channels with the following channel name corresponding to the Pin on the board:

        Analog input channel (ADC) Pin on board
        0 PA0
        1 PA1
        2 PA2
        3 PA3
        4 PA4
        5 PA5
        6 PA6
        7 PA7
        8 PB0
        9 PB1
        10 PC0
        11 PC1
        12 PC2
        13 PC3
        14 PC4
        15 PC5

        Analog output channels (DAC)
        There are 2 DAC channels and each correspond to a port as follow:

        Analog output channel (DAC) Pin on board
        1 PA4
        2 PA5

        AnaloglastWrite() function can be used to retrieve the last value written to the analog output (DAC) channel. For example, to get the last value written to analog output channel 2:

        int lastvalue;
        lastvalue=analogLastwrite(2);

        Interrupt note
        There are total 16 interrupt channels for digital input pins, the interrupt. Each pin ‘number’ can only be assigned an interrupt. This means that interrupt cannot be assigned to PA5 and PB5 at the same time as the pin ‘number’ are the same.
        (note: the interrupt handling function must appear before main() directive of the program if not declaring a function prototype)

        pause(ms) and pauseMicroseconds(us)
        (delay possible within interrupt routine)
        Generally the use of delay functions are not possible within the interrupt handling routine and this is where pause(ms) and pauseMicroseconds(us) comes in. Just specify the number of milliseconds/microseconds to pause the program and pause will handle it even within the interrupt. Note that pause only “approximate” the time to delay.
        Example: to pause for approximately 10 milliseconds

        pause(10);

      Xduino currently supports the following ARM Cortex-M3 STM32f103ret6 board.

      Price: US$30 + $10shipping
      (Contact us here to buy)

      Currently 5 in stock

      (the shipping price is for Europe, treatment
      USA, physician
      India, Singapore for other countries please contact us)
      (for big quantity order please email us)

      ARM STAMP Cortex-M3 STM32F10ret6 board

      ARM STAMP Cortex-M3 STM32F10ret6 board

      If you are interested in getting this board you can contact us.
      The board has following features:

      • 5 Serial ports
      • 48 General purpose input/output pins (GPIO)
      • 16 Analog input channels 12-bits (ADC)
      • 2 Analog output channels 12-bits (DAC)
      • 512 Kbytes of Flash memory
      • 68 Kbytes of RAM
      • 3 SPI ports (2 can do I2S)
      • 2 I2C
      • 1 USB
      • 1 CAN
      • 1 SDIO
        • Use MCU 32Bit ARM Cortex-M3 64Pin (LQFP) of “STmicroelectronics”
        • Use Crystal 8.00MHz + Phase-Locked Loop (PLL), Run 72MHz frequency with speed 1.25 DMIPS/MHz to process data that is equivalent to 90MIPS
        • Has RTC (Real Time Clock) Circuit with XTAL 32.768KHz and Battery Backup connector
        • Support In-System Programming (ISP) and In-Application Programming (IAP) through On-Chip Boot-Loader Software via Port USART1 (RS232)
        • Has RS232 Communication Circuit that uses Connector 4-PIN
        • Has 48 Bit GPIO with 5V-Tolerant for independent digital applications (maximum analog input is 3.3V)
        • Use +3.3V Power Supply
        • Connector is placed on 50 Pin Header with a distance of 2.54mm (100mil) (25 pins per side) with a distance of 1.5 inch (1500mil/38.1mm), so it is quite easy to use and expand I/O Circuit. Moreover, it can be used with Project Board and PCB.
      Be Sociable, Share!
      Share
    1. #1 by Dwain Crackel on August 20th, 2009

      I’m trying to make contact about purchase of a xduino, and the contact us page seems to echo my message to my email, rather than sending it you.

    2. #2 by Ram on August 21st, 2009

      Please check your email filter it might have caught my reply. : -)

    3. #3 by Fredjikrang on August 24th, 2009

      Have you been in contact with these guys? http://blogs.leaflabs.com/?p=91

      Because it looks like you are working on very similar things. If not, you should get in touch with them and see if you could work together on this. 😀

    4. #4 by Ram on August 30th, 2009

      I have left a note on their blog site and did not receive anything in return. So let’s see what happens.

    5. #5 by jose on September 3rd, 2009

      Hi

      How can I program the hardware?
      What do I need?, jtag, serial, ?

      Thanks
      Jose

    6. #6 by Ram on September 6th, 2009

      The board can be programmed directly via the built-in RS232 serial connection.
      So just plug the cable to the computer and it’s ready to be programmed.
      JTAG is not needed : -).

    7. #7 by julian on October 26th, 2011

      Hi
      I am looking at
      developing a pid type controller, at start as a pc input output, and
      when code is optimised as a standalone.
      This is for a sousvide
      controller using either i2c / ds18b20 temperature input and ssr output

      (I will also use it for brewing mash control, and possibly a time
      tmperature central heatng system too!)To this end i will need to record
      temp data to tune my alogorithms
      Is the ARM Cortex-M3 STM32f103ret6 Module suitable?

      Are there any help available?
      I program in c++ but am an idiot as far
      as hardware goes!
      thanks
      Julian

    Comments are closed.