Jump to content


  • Content Count

  • Joined

  • Last visited

About dino7

  • Rank
    Noob Class
  • Birthday 12/20/1978

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Westland, The Netherlands
  • Interests
    Micro controllers specifically. Electronics, model railroading, rc.
  1. Thanks, did not know srand() existed (even for avr so it seems). So, in essence I reinvented the wheel. Thanks for the embtextf link, will have a look into that.
  2. In an attempt to port one of my projects from AVR to the MSP430G2553 and failing horribly because the printf() function in CCS does not fit into the 512 bytes RAM, I did manage to port a single function. The function, READrnd(), reads some pre generated random numbers from flash memory. I use them to give my projects some (predefined) randomness. For example, the project I want to port uses the predefined random numbers to "randomly" turn on and off 8 relays. I am going to use it for some night/day simulation in houses on a model railroad track. Anyway, with the MSP430 version of the online number generator you can generate random numbers. Here are the sources. randomvals.h: /* generated using: http://atoomnet.net/?p=462 */ #ifndef RANDOMVALS_H_ #define RANDOMVALS_H_ //32 guaranteed random numbers const uint8_t random0[] PROGMEM = { 0x87, 0x22, 0xFB, 0x0D, 0x23, 0x03, 0x60, 0x3F, 0x7A, 0x65, 0xC5, 0xF2, 0x10, 0xF2, 0x2A, 0xB3, 0x7D, 0xD4, 0x5D, 0x8B, 0xD5, 0xF5, 0x1B, 0x4C, 0xC7, 0x45, 0xAF, 0x5E, 0x81, 0xAB, 0x71, 0xF8, }; #endif /* RANDOMVALS_H_ */ random.h: #ifndef RANDOM_H_ #define RANDOM_H_ #include <stdint.h> uint8_t READrnd(void); #endif /* RANDOM_H_ */ random.c: #include <stdint.h> #include "randomvals.h" uint16_t ptrRnd = 0; //Read a random value from randomvals.h, wrap when reaching the end of the table. uint8_t READrnd() { uint8_t rnd = random0[ptrRnd++]; if (ptrRnd==sizeof(random0)) ptrRnd = 0; return rnd; } With these files you have (in this example) 32 bytes of random numbers to work with. Here is the example program running on the TI launchpad I used to test the above sources. Led1 and led2 will flash seemingly random. main.c: #include <msp430.h> #include <stdint.h> #include "random.h" int main(void) { int i; WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1DIR = 0xFF; //Port 1 all pins output for(; { uint8_t randomValue = READrnd(); //Get 8-bit random value from array P1OUT = randomValue; //Output random value to port 1 //Do nothing for some time for(i = 10000; i >= 0; i--) asm("nop"); } } All settings are default except the optimization: -O4 --opt_for_speed=0 The asm("nop") forces the compiler to not optimize away the (for it) pointless for-loop. I hope you like it and, as a beginner in the MSP430 architecture all feedback is welcome.
  3. Hi there! I just registered on this forum to learn more about the msp430 microcontroller. I have started working with 8 bit avr micro controllers before the turn of the century starting with the at90s1200 (the very first, no RAM). Hope I am welcome here. Yesterday I found a post in the beginners forum pointing out that you need both the data sheet and the family guide to understand how to program a msp430. Helped me a lot. With 8 bit avr's you get them in one datasheet. On my left is a msp430 launchpad wildly binking its leds at me Met vriendelijke groet, Marc The Netherlands.
  • Create New...