Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by oPossum

  1. You could also try: BPM = (unsigned)60000L / (unsigned)milliseconds; Not 100% sure that will generate working code. CCS may not have unsigned / unsigned divide.
  2. Here is some code for random number generation using ADC noise. This can be used for seeding a PRNG. The ADC input used should be left floating - not connected to anything. The distribution is probably quite bad - I suspect it is lumped near the center. unsigned adc_rnd(void) { unsigned n; unsigned b = 16; do { ADC10CTL0 |= ADC10SC; // Start ADC conversion while(!(ADC10IFG & ADC10IFG0)); // Wait for conversion complete n <<= 1; // Make room for a bit n |= (ADC10MEM0 & 1); // Append lsb of ADC reading } while(--; return n ^ 0x5555; } // I
  3. send((seconds >> 4) + '0'); send((seconds & 0x0F) + '0');
  4. Yes, variables, registers, memory. Anything writable. To see variables in the current function, just click on the local tab. No need to watch them. Double click in the left margin (grey area) to set or clear a breakpoint.
  5. If there is a stub handler in the GRACE code, then your interrupt function probably should not have the __interrupt attribute. I suspect your program is crashing due to stack corruption cause by improper function return. (reti vs. ret)
  6. Yes, I think that may be the case. The problem is that it must immediately precede the code you want called by that vector.
  7. That error means an interrupt vector is declared more than once. There may be something in csl.h causing this problem. Don't remove the #pragma vector=PORT1_VECTOR line, your code will not work without it. The interrupt code will not be called because the vector does not point to it.
  8. It takes some time to respond to an interrupt, so the value you read from the timer will always be a bit off. There are many things that affect interrupt latency, so it is not possible to compensate for it accurately. The timer capture will save the timer value when a pin changes state and then optionally trigger an interrupt. The interrupt latency does not matter because the timer value has been saved in the capture register.
  9. oPossum

    SD16 Help

    On the inverting (-) or non-inverting (+) input? I think you need a 600 mV bias on inverting (-) input to get 0 to 1.2 volt range on non-inverting (+) input.
  10. oPossum

    SD16 Help

    What is the inverting (-) input connected to? Ground? I assume it would have to be biased above ground to get full +/- range.
  11. Using FRAM for a frame buffer seems to have some problems. There are video artifacts that I assumed where due to instruction cache misses causing clock jitter, but running at 8 MHz clock did not fix that problem. I also may have damaged some of the FRAM - there are some bits that are no longer programmable. So, I am going to switch to a MSP430F5418A and use part of the 16K SRAM as frame buffer. That should fix the video artifact problem and also be a little faster. I added some primitive 3D functions, so here is the obligatory 3D cube (with very noticeable artifacts)... Al
  12. The first font that I used with this was from the MC6847 used by the CoCo 1/2. I had that font in the form of a C array. Many years ago I wrote an emulator for all of the Tandy/Radio Shack home computers. I think it was the first emulator to do MC-10, Model 100 and Tandy 200. The others had been done before. It may be possible to emulate some of the old home computers with an MSP430, but I think it would be very slow. My M80 (Multiple eMulator of TRS-80) emulator running all supported systems concurrently...
  13. This link: http://focus.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=slau157&fileType=pdf will be the latest version.
  14. Quadrature or gray encoder?
  15. Those are all PM package (64 pin LQFP). The G4, R and RG4 designate how chips are packaged together - such as tape reel or tray. TI Package Info
  16. struct tm bt; bt.tm_hour = 12; // Hour bt.tm_min = 0; // Minute bt.tm_sec = 0; // Second bt.tm_mon = 7; // Month bt.tm_mday = 17; // Day bt.tm_year = 2011; // Year bt.tm_isdst = 0; // DST bt.tm_wday = 0; // Day of week bt.tm_yday = 0; // Day of year time_t seconds = mktime(&bt); // Convert time/date to seconds
  17. Use the functions in time.h #include "time.h" const time_t time = 1234; // Time in seconds struct tm *lt = localtime(&time); // Convert to date & time for local time zone
  18. The MSP430F1612 on the Launchpad provides a 12 MHz clock to the TUSB3410 chip. This clock can also be used by the MSP430 in the 20 pin socket. Clock on pin 49 of F1612 Mask off pin 49 with Kapton tape and solder a 1k resistor to the pin. Connect the other end of the resistor to the lower pad of C21 using a short wire. This test program will flash the red LED five times with the DCO at ~1 MHz and then switch to the 12 MHz external clock. #include "msp430g2231.h" void main(void) { unsigned i; volatile unsigned n = 0; WDTCTL = WDTPW | WDTHOLD; P1DIR = 0x0
  19. The firmware must control the SS line(s). The hardware has no idea how long a packet is.
  20. Yes, any multiple of 7 or 8 bits. For many SPI peripherals, the SS or CS line is used to reset the internal SPI shift register. So to send a packet to the chip, assert SS, send one or more 7 or 8 bit chunks, and then deassert SS. Note that the STEN line is always an input and is used for optional muti-master arbitration in master mode. It is not used to control SS/CS of slaves on the bus. 4 wire master mode is not the same as a 4 wire SPI connection.
  21. Using a 32768 Hz xtal for the phase accumulator clock is a very clever idea. I like it. Here is some code that seems to work. I just briefly tested it, so there may be some bugs. Timer A is switched between ACLK at 32768 Hz and SMCLK at ~16 MHz as needed. This will generate two sine waves with a frequency resolution of 0.5 Hz. This is the core code... // Phase increments are in units of 0.5 Hz static unsigned pi1 = 440 * 2; // Phase increment 1 static unsigned pi2 = 660 * 2; // Phase increment 2 void main(void) { WDTCTL = WD
  • Create New...