Jump to content
43oh

zeke

Members
  • Content Count

    1,786
  • Joined

  • Last visited

  • Days Won

    102

Reputation Activity

  1. Like
    zeke reacted to bluehash in Shipping to Canada?   
    Added.
  2. Like
    zeke reacted to gwdeveloper in Hitachi Analog Oscilloscope [PPU]   
    Hey guys, I've got an older analog oscilloscope I'd like to get rid of.
     
    Hitachi V-202F 20MHz
    2 Channel
    Includes 2 Tektronix Probes with Screw On Tips #013-0071-00
    Includes short ground lead
     
    Some of the knobs need a bit of cleaning but everything is functional. Again, it's completely analog so there is no RS-232, USB or SD Card storage. Probably not much use anymore as a digital tool but could be used as a toy. This past x-mas I had a LP draw x-mas trees scrolling across the screen.
     
    Here's the kicker... It's FREE! You just have to pay the shipping which will most certainly be not Free.
     
    EDIT: Pending pickup by xtjacob
  3. Like
    zeke got a reaction from cubeberg in Free Noritake Display give-away   
    Uhm... I guess I am a whiner. Ooops. Winner.
     
    I sent them an email claiming that it wasn't fair to exclude Canada. They agreed and sent me a dev kit. 8-)
     

     

     
    As you can see, it's a monster!
     
    Kudos to Noritake for being so kind and generous! :clap:
     
    VFDs for Everyone!
  4. Like
    zeke got a reaction from RobG in Free Noritake Display give-away   
    Uhm... I guess I am a whiner. Ooops. Winner.
     
    I sent them an email claiming that it wasn't fair to exclude Canada. They agreed and sent me a dev kit. 8-)
     

     

     
    As you can see, it's a monster!
     
    Kudos to Noritake for being so kind and generous! :clap:
     
    VFDs for Everyone!
  5. Like
    zeke reacted to oPossum in USCI UART bit rate setting   
    The MSP430x2xx Family User's Guide has several forumulas and tables for UART bit rate calculation. Makes it look more complicated than it is. Here is simple code to setup the bit rate divisor and modulator (for oversampling mode).
     
    First you need to know the SMCLK frequency and the desired bit rate.

    const unsigned long smclk_freq = 16000000; // SMCLK frequency in hertz const unsigned long bps = 19200; // Async serial bit rate Then a 20 bit divisor value can be calculated.
    const unsigned long brd = (smclk_freq + (bps >> 1)) / bps; // Bit rate divisor Shift and mask to setup the registers.
    UCA0BR1 = (brd >> 12) & 0xFF; // High byte of whole divisor UCA0BR0 = (brd >> 4) & 0xFF; // Low byte of whole divisor UCA0MCTL = ((brd << 4) & 0xF0) | UCOS16; // Fractional divisor, oversampling mode That's it! 
    A function for UART setup at a specified bit rate...

    const unsigned long smclk_freq = 16000000; // SMCLK frequency in hertz void setup_UART(const unsigned long bps) // Async serial bit rate { const unsigned long brd = (smclk_freq + (bps >> 1)) / bps; // Bit rate divisor UCA0CTL1 = UCSWRST; // Hold USCI in reset to allow configuration UCA0CTL0 = 0; // No parity, LSB first, 8 bits, one stop bit, UART (async) UCA0BR1 = (brd >> 12) & 0xFF; // High byte of whole divisor UCA0BR0 = (brd >> 4) & 0xFF; // Low byte of whole divisor UCA0MCTL = ((brd << 4) & 0xF0) | UCOS16; // Fractional divisor, oversampling mode UCA0CTL1 = UCSSEL_2; // Use SMCLK for bit rate generator, release reset }
  6. Like
    zeke reacted to oPossum in Dual-edge interrupts on one pin   
    Noisy switches can cause port interrupts to rapid fire and hog the CPU. This can cause unexpected behavior of other ISRs and/or mainline code. Best practice is to debounce in a timer interrupt.
     
    This is a simple debounce that operates similar to a cap in parallel with the switch and a pullup resistor.
    The variable debounce will be zero when the switch is open and non-zero when it is closed. Note that it is not boolean.
    The expression returns the value of debounce.

    volatile unsigned debounce = 0; #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer0_A0 (void) { // Reset debounce timeout if switch is closed, else decrement timeout if not zero ((P1IN & BIT3) ? (debounce ? --debounce : 0) : (debounce = 25)); }
     
    This code allows action to be taken on transitions and also provides a bool variable with switch state.
    It is necessary to have two variables so that current debounce state can be compared to previous state.

    volatile unsigned debounce = 0; volatile unsigned switch_on = 0; #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer0_A0 (void) { // Debounce and check if switch state has changed if(switch_on != (0 != ((P1IN & BIT3) ? (debounce ? --debounce : 0) : (debounce = 25)))) { // Update switch state and test direction of transition if(switch_on = !switch_on) { // Switch has closed } else { // Switch has opened } } }
  7. Like
    zeke got a reaction from Fe2o3Fish in Anyone notice the 8-pin MSP430 yet?   
    Presenting the MSP430G2230.
     
    Only 8 pins!
  8. Like
    zeke got a reaction from nuetron in Anyone notice the 8-pin MSP430 yet?   
    Presenting the MSP430G2230.
     
    Only 8 pins!
  9. Like
    zeke got a reaction from turd in Anyone notice the 8-pin MSP430 yet?   
    Presenting the MSP430G2230.
     
    Only 8 pins!
  10. Like
    zeke got a reaction from timotet in Anyone notice the 8-pin MSP430 yet?   
    Presenting the MSP430G2230.
     
    Only 8 pins!
  11. Like
    zeke got a reaction from oPossum in Anyone notice the 8-pin MSP430 yet?   
    Presenting the MSP430G2230.
     
    Only 8 pins!
  12. Like
    zeke got a reaction from RobG in Anyone notice the 8-pin MSP430 yet?   
    Presenting the MSP430G2230.
     
    Only 8 pins!
  13. Like
    zeke reacted to SugarAddict in $4.30 LCD Booster - Sold Out   
    I'll be sending Bluehash ~80 of them or so for the store. I'm thinking he should limit it to 2 a person... considering the amount of people here and the limited stock (plus it's a loss item, lol, ya'll'r gettin a steal :ugeek: :thumbup: )
  14. Like
    zeke reacted to oPossum in Comprehensive DCO calibration   
    The G series MSP430 have 1 or 4 factory calibrations for the DCO stored in info segment A. This firmware will store 96 DCO calibrations in info segments B, C, and D. After these calibrations have been stored it is possible to set the DCO to any frequency from 125 kHz to 16 MHz (128:1 range) with a simple function call...
     
    set_dco.c

    #include static const unsigned * const InfoSegA = (unsigned *)0x10C0; static const unsigned * const InfoSegD = (unsigned *)0x1000; int set_dco(const unsigned f) // Set DCO to specified frequency in kHz { // unsigned i; // unsigned rsel = 0; // Init rsel/dco unsigned dco = 0x20; // const unsigned *cal = InfoSegD; // Begin at info segment D do { // if(f >= cal[0] && f < cal[1]) { // Frequency in range? i = cal[1] - cal[0]; // Interpolate for MODx dco += ((((f - cal[0]) * 0x20) + (i >> 1)) / i); DCOCTL = dco; // Set the DCO/MOD BCSCTL1 = rsel; // and RSEL return 0; // Return success } // if((dco += 0x20) == 0xC0) // Next DCO/RSEL dco = 0x20, ++rsel, ++cal; // } while(++cal < InfoSegA); // While in info seg D, C, or B return -1; // Return failure }
     
    Make sure that CCS is configured to write only to main memory so the calibration constants are not erased. This is not the default configuration.

     
    The following code writes the DCO calibrations to the info segments. This only has to be done once for a specific chip. A 32 kHz crystal must be installed while this code is running, but is no longer needed once the calibration has been written.
     
    Serial output while running calibration...

    Info Segments - before calibration D 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, C 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, B 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,65535,65535,65535, A 35969,5886,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,4112,32786,0, 32209,742,0,32332,437,0,2302,65535, 65535,65535,65535,2049,36757,36504,36234,34506, Calibrating... 99,106,114,123,134,146,122,131, 141,152,165,181,170,182,196,212, 229,251,241,258,278,299,323,354, 338,361,388,418,450,493,484,517, 555,596,642,703,673,718,770,827, 891,973,949,1012,1084,1163,1252,1368, 1348,1437,1538,1649,1776,1937,1924,2048, 2189,2346,2526,2754,2738,2911,3109,3329, 3586,3906,3520,3746,4007,4299,4635,5057, 4731,5032,5374,5761,6213,6770,6427,6824, 7278,7786,8385,9123,9350,9928,10587,11331, 12209,13283,12672,13414,14248,15200,16325,17715, Info Segments - after calibration D 99,106,114,123,134,146,122,131, 141,152,165,181,170,182,196,212, 229,251,241,258,278,299,323,354, 338,361,388,418,450,493,484,517, C 555,596,642,703,673,718,770,827, 891,973,949,1012,1084,1163,1252,1368, 1348,1437,1538,1649,1776,1937,1924,2048, 2189,2346,2526,2754,2738,2911,3109,3329, B 3586,3906,3520,3746,4007,4299,4635,5057, 4731,5032,5374,5761,6213,6770,6427,6824, 7278,7786,8385,9123,9350,9928,10587,11331, 12209,13283,12672,13414,14248,15200,16325,17715, A 35969,5886,65535,65535,65535,65535,65535,65535, 65535,65535,65535,65535,65535,4112,32786,0, 32209,742,0,32332,437,0,2302,65535, 65535,65535,65535,2049,36757,36504,36234,34506, Done
     
    Calibration code...
     
    main.c

    #include void putc(unsigned); // serial_tx.asm void puts(char *); // serial_tx.asm void utoa(unsigned, char *); // utoa.asm static char s[8]; // buffer for printing unsigned int // Address of info segments static unsigned * const InfoSegA = (unsigned *)0x10C0; static unsigned * const InfoSegB = (unsigned *)0x1080; static unsigned * const InfoSegC = (unsigned *)0x1040; static unsigned * const InfoSegD = (unsigned *)0x1000; /* Freq = Count / Time Freq = Count / (100 / 32768) <-- 100 cycles of 32.768 kHz clock Freq (kHz) = Count / ((100 / 32768) * 1000) Freq (kHz) = Count / 3.0517578125 Freq (kHz) = Count * (1 / 3.0517578125) Freq (kHz) = Count * 0.32768 Freq (kHz) ~= (Count * 21475) / 65536 Freq (kHz) ~= (Count * 21475) >> 16 Freq (kHz) ~= ((Count * 21475) + 32768) >> 16 <-- Better rounding */ void cal_block(unsigned *d, unsigned rsel, unsigned dco) { unsigned n = 32; // Do 32 cals beginning at rsel/dco with // dco range of 0x20 to 0xA0 using 0x20 step // - no modulation - 6 values per rsel DCOCTL = 0; // DCOCTL = dco & 0xE0; // Set initial DCOx, MODx == 0 BCSCTL1 = rsel; // Set initial RSELx do { // __delay_cycles(3277); // Wait for DCO to settle for 100 ms TACTL |= TACLR; // Clear TimerA TACTL |= MC_2; // Start counting - TimerA continuous mode __delay_cycles(100 - 5); // 100 cycles (5 overhead from previous and next instructions) TACTL &= ~MC_2; // Stop counting - TimerA stop mode // *d++ = ((21475L * TAR) + 32768) >> 16; // Scale to kHz // if((DCOCTL += 0x20) == 0xE0) { // Increment DCOx, check if limit reached DCOCTL = 0x20; // Reset DCOx ++BCSCTL1; // Next RSELx } // } while(--n); // } void cal_write(const unsigned *c, unsigned *f) { // Write one full info segment - 64 bytes / 32 ints unsigned n; // DCOCTL = 0; // Run DCO at 1 MHz BCSCTL1 = CALBC1_1MHZ; // DCOCTL = CALDCO_1MHZ; // FCTL2 = FWKEY | FSSEL_2 | 3 - 1; // SMCLK / 3 for flash timing generator FCTL3 = FWKEY; // Clear lock bit FCTL1 = FWKEY | ERASE; // Set erase bit *f = 0; // Dummy write to erase segment FCTL1 = FWKEY | WRT; // Set wrt bit for write operation n = 32; do *f++ = *c++; while(--n); // Write flash FCTL1 = FWKEY; // Clear wrt bit FCTL3 = FWKEY | LOCK; // Set lock bit } void show_block(const unsigned *c) { // Show 32 unsigned ints unsigned a, b; // a = 4; // 4 lines do { // b = 8; // 8 columns do { // utoa(*c++, s); // Unsigned to ASCII puts(s); // Print it putc(','); // } while(--; // Next column puts("\r\n"); // Next line } while(--a); // } void show_all_info_segs(void) { puts("D\r\n"); // show_block(InfoSegD); // D puts("C\r\n"); // show_block(InfoSegC); // C puts("B\r\n"); // show_block(InfoSegB); // B puts("A\r\n"); // show_block(InfoSegA); // A puts("\r\n"); // } void main(void) // { // unsigned n; // unsigned cal[32]; // WDTCTL = WDTPW | WDTHOLD; // Disable watchdog reset // TACTL = TASSEL_2; // SMCLK (DCO) // P1DIR = BIT1; // P1OUT = BIT1; // // BCSCTL3 = XCAP_2; // 10 pF n = 0; // do { // - Wait for MSP430 to detect clock is stable IFG1 &= ~OFIFG; // Clear OFIFG while(--n); // Wait a while } while(IFG1 & OFIFG); // Loop until OFIFG remains cleared BCSCTL2 = SELM1 | SELM0; // - Use LFXT1CLK (32 kHz xtal) as clock source // // Show all the info segments before calibration puts("Info Segments - before calibration\r\n"); show_all_info_segs(); // // puts("Calibrating...\r\n"); // Do calibration and write to flash info segments D to B // cal_block(cal, 0, 0x20); // Calibrate cal_write(cal, InfoSegD); // Write show_block(cal); // Show on terminal // cal_block(cal, 5, 0x60); // cal_write(cal, InfoSegC); // show_block(cal); // // cal_block(cal, 10, 0xA0); // cal_write(cal, InfoSegB); // show_block(cal); // // puts("\r\n"); // // Show all the info segments after calibration has been written puts("Info Segments - after calibration\r\n"); show_all_info_segs(); // // puts("Done\r\n"); // // for(;; // }
     
    serial_tx.asm

    .cdecls C, LIST, "msp430g2211.h" .text .def putc, puts ; 32768 Hz / 2400 bps = 13.6533 cycles per bit ~= 41 cycles per 3 bits (14 / 13 / 14) ; Char to tx in R12 putc: or #0x0100, R12 ; Stop bit mov #0x02, R15 ; Serial out bitmask jmp bit_start ; ; bit0: jmp $ + 2 ; jmp $ + 2 ; nop ; rra R12 ; Bit 0/3/6 jc bit0h ; bic.b R15, &P1OUT ; 14/55/96 jmp bit1 ; bit0h: bis.b R15, &P1OUT ; 14/55/96 jmp bit1 ; ; bit1: jmp $ + 2 ; jmp $ + 2 ; rra R12 ; Bit 1/4/7 jc bit1h ; bic.b R15, &P1OUT ; 27/68/109 jmp bit2 ; bit1h: bis.b R15, &P1OUT ; 27/68/109 jmp bit2 ; ; bit2: jmp $ + 2 ; jmp $ + 2 ; nop ; rra R12 ; Bit Start/2/5/Stop jc bit2h ; bit_start: bic.b R15, &P1OUT ; 0/41/82/- jmp bit0 ; bit2h: bis.b R15, &P1OUT ; -/41/82/123 jne bit0 ; ret_ins: ret puts: ; Tx string using putc mov R12, R14 ; String pointer in R12, copy to R14 putsloop: ; mov.b @R14+, R12 ; Get a byte, inc pointer tst.b R12 ; Test if end of string jz ret_ins ; Yes, exit... call #putc ; Call putc jmp putsloop ; ; .end ;
     
    utoa.asm

    .cdecls C, LIST, "msp430g2211.h" .text .def utoa utoa: ; --- Unsigned to ASCII --- ; - Range 0 to 65535 ; - Leading zeros supressed push R10 ; clr R14 ; Clear packed BCD .loop 13 ; Do 13 bits rla R12 ; Get bit 15 to 3 of binary dadd R14, R14 ; Multiply BCD by 2 and add binary bit .endloop ; clr R15 ; Clear digit 1 of packed BCD .loop 3 ; Do 3 bits rla R12 ; Get bit 2 to 0 of binary dadd R14, R14 ; Multiply BCD by 2 and add binary bit dadd R15, R15 ; .endloop ; swpb R14 ; Swap digit order mov R14, R12 ; Copy packed BCD digits and #0x0F0F, R12 ; Mask digits 5 & 3 rra R14 ; Shift digits 4 & 2 to lower nibble rra R14 ; rra R14 ; rra R14 ; and #0x0F0F, R14 ; Mask digits 4 & 2 mov #('0' << 8) | '0', R10 ; Make ASCII add R10, R12 ; add R10, R14 ; add R10, R15 ; cmp.b R10, R15 ; Is first digit a 0? jne dig5 ; No... cmp.b R10, R14 ; Is second digit a 0? jne dig4 ; No, only the first... cmp.b R10, R12 ; Is third digit a 0? jne dig3 ; No, only the first two... cmp R10, R14 ; Is fourth digit a 0? (second is zero) jne dig2 ; No, only the first three... dig1: ; First four digits are all 0 swpb R12 ; Fifth digit to string mov.b R12, 0(R13) ; inc R13 ; clr.b 0(R13) ; NULL terminate string pop R10 ; ret ; Return ; dig5: ; mov.b R15, 0(R13) ; First digit to string inc R13 ; dig4: ; mov.b R14, 0(R13) ; Second digit to string inc R13 ; dig3: ; mov.b R12, 0(R13) ; Third digit to string inc R13 ; dig2: ; swpb R14 ; Fourth digit to string mov.b R14, 0(R13) ; inc R13 ; jmp dig1 ;
  15. Like
    zeke reacted to V0JT4 in I2C USCI_B0 Slave?   
    Check out USCI I2C documentation, you have to shift device ID >>1, it takes only 7 low bits unlike what you see on the bus. That's the reason why your slave doesn't send ACK.
  16. Like
    zeke got a reaction from Accoutkic in 43oh needs a shot of Uggcitrin   
    Not a chance! I don't need the extra work
  17. Like
    zeke got a reaction from gordon in Serial EEPROM   
    Looks like the site is back up.
     
    Cool!
  18. Like
    zeke reacted to oPossum in Semi-automatic DCO characterization   
    This firmware will measure the frequency of all 4,096 possible DCO settings and send that information to the host computer as CSV (comma separated values) data at 2400 bps. Just capture the serial data to a text file and view it in your favorite spreadsheet program. The 32 kHz watch crystal is required for this firmware, it is used as reference timebase for serial tx and frequency measurement. I think this will run on all G series chips, and may also work on F2000 series.
     
    The vertical axis is frequency on a log scale.
    The horizontal axis DCOCTL (DCOx, MODx)
    The 16 plots are RSELx (lower 4 bits of BCSCTL1)

     
    dco.csv

    ,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, 0,91,92,92,92,92,92,93,93,93,93,93,94,94,94,94,94,94,94,95,95,95,95,95,96,96,96,96,96,96,96,97,97,97,97,98,98,98,98,99,99,99,99,99,100,100,100,100,100,101,101,101,101,101,102,102,102,102,102,103,103,103,103,104,104,104,104,105,105,105,105,106,106,106,106,107,107,107,107,107,108,108,108,108,109,109,109,109,110,110,110,110,111,111,111,112,112,112,112,113,113,113,114,114,114,114,115,115,115,115,115,116,116,116,116,117,117,117,118,118,118,119,119,119,119,120,120,120,121,121,122,122,122,122,123,123,123,124,124,124,125,125,125,126,126,126,127,127,127,128,128,128,129,129,130,130,130,130,131,131,132,132,133,133,133,133,134,134,134,135,135,135,136,136,137,137,137,138,138,139,139,140,140,141,141,141,142,142,142,143,143,144,144,145,145,146,146,147,147,147,148,148,149,149,150,150,151,151,152,152,153,153,154,154,154,155,155,156,157,157,158,158,159,159,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160 1,114,115,115,115,115,115,115,116,116,116,116,116,117,117,117,117,118,118,118,118,119,119,119,119,120,120,120,120,121,121,121,121,122,122,122,122,122,123,123,123,124,124,124,124,125,125,125,125,126,126,126,127,127,127,127,128,128,128,129,129,129,129,130,130,130,131,131,131,131,132,132,132,133,133,133,133,134,134,134,135,135,135,135,136,136,136,137,137,137,138,138,138,139,139,139,139,140,140,140,141,141,141,142,142,143,143,143,143,144,144,145,145,145,146,146,146,147,147,148,148,148,149,149,149,150,150,150,151,151,152,152,153,153,154,154,154,154,155,155,156,156,156,157,157,157,158,158,159,159,160,160,161,161,161,162,162,163,163,164,164,165,165,166,166,166,167,168,168,169,169,169,170,170,171,171,172,172,173,173,174,174,175,175,176,176,177,177,178,178,179,179,180,180,181,182,182,183,183,184,184,185,186,186,187,188,188,189,189,190,191,191,192,192,193,193,194,195,195,196,197,197,198,199,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200 2,158,159,159,159,160,160,160,160,161,161,161,162,162,162,163,163,163,164,164,165,165,165,165,166,166,166,167,167,167,168,168,168,169,169,170,170,170,170,171,171,172,172,172,173,173,173,174,174,174,175,175,175,176,176,177,177,177,178,178,178,179,179,180,180,181,181,181,182,182,182,183,183,184,184,184,185,185,186,186,187,187,188,188,189,189,189,190,190,191,191,192,192,192,193,193,193,194,194,195,195,196,196,197,197,198,198,199,199,200,200,200,201,202,202,202,203,204,204,205,205,206,206,207,207,208,208,209,209,210,210,211,211,212,212,213,213,214,215,215,216,216,217,217,218,219,219,220,220,221,222,222,223,224,224,225,225,226,227,227,228,228,229,230,230,231,231,232,232,233,234,235,235,236,237,237,238,239,239,240,241,242,242,243,244,244,245,246,247,247,248,249,250,250,251,252,253,253,254,255,256,256,257,258,259,260,261,261,262,263,264,265,266,266,268,268,269,270,271,272,272,273,274,275,276,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277 3,224,225,225,226,226,226,227,227,227,228,229,229,230,230,230,231,231,231,232,232,233,233,234,234,234,235,236,236,236,237,238,238,239,239,239,240,240,241,242,242,243,243,243,244,244,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,254,254,255,255,256,256,257,258,258,258,259,260,260,261,262,262,263,263,264,265,265,266,266,267,267,268,269,269,270,270,271,272,272,273,274,274,275,275,276,277,278,278,279,279,280,281,282,282,283,284,284,285,286,286,287,288,288,289,289,290,291,292,293,293,294,295,296,296,297,298,299,299,300,301,302,303,303,304,305,306,307,307,308,309,310,310,311,312,313,314,315,315,316,317,318,319,320,321,322,322,323,324,325,326,327,328,329,330,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,354,354,355,357,358,359,360,361,362,364,365,366,367,368,369,370,371,372,374,375,376,377,378,380,381,382,384,385,386,387,389,390,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391,391 4,312,313,314,314,315,315,316,316,317,318,318,319,320,320,321,322,322,323,323,324,325,325,326,327,328,328,329,329,330,331,331,332,333,333,334,335,335,336,337,337,338,339,339,340,341,342,342,343,344,345,345,346,347,347,348,349,350,350,351,351,353,353,354,355,355,356,357,358,359,359,360,361,362,363,364,364,365,366,367,367,368,369,370,371,372,373,373,374,375,376,377,377,379,380,380,381,382,383,384,385,386,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,405,406,408,409,409,411,412,413,414,415,416,417,418,419,420,421,423,423,425,425,427,428,429,430,431,432,433,434,436,437,438,439,440,442,443,444,445,446,447,449,450,451,452,454,455,456,457,459,460,461,463,463,465,466,468,469,470,472,473,474,476,477,479,480,482,483,484,486,487,489,490,492,493,495,496,498,499,501,502,504,505,507,508,510,512,513,515,516,518,520,521,523,525,526,528,530,532,533,535,537,539,541,542,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544 5,448,449,450,451,451,452,453,454,455,456,456,458,459,459,460,461,462,463,464,465,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,483,484,485,486,487,488,489,490,491,492,494,495,496,497,498,498,500,501,502,503,504,505,506,507,508,509,510,511,512,514,515,516,517,519,519,521,522,523,524,525,526,527,529,530,531,532,533,535,536,537,538,540,541,542,543,544,546,547,548,550,551,552,554,555,556,557,559,560,561,563,564,565,567,568,569,571,572,574,575,577,578,579,580,582,583,585,586,588,589,591,592,594,595,597,598,600,601,603,604,605,607,609,610,612,613,615,617,618,620,621,623,625,626,628,630,632,633,635,637,638,640,642,643,645,647,649,650,652,654,656,658,659,661,663,665,667,669,671,673,675,676,678,680,682,684,686,688,690,692,694,696,698,700,702,705,707,709,711,713,715,717,719,722,724,726,728,731,733,735,737,740,742,745,747,750,752,754,757,759,762,764,766,769,772,774,777,777,777,777,777,776,776,777,776,777,777,777,776,776,776,776,777,776,777,777,776,777,777,777,776,776,776,777,777,777,777,777 6,619,621,622,623,624,625,627,628,629,630,631,632,634,635,636,637,638,640,641,642,643,645,646,647,648,650,651,652,654,655,656,657,658,660,661,662,664,666,666,668,669,670,672,673,674,676,677,679,680,682,683,684,685,687,689,690,691,693,694,695,697,699,700,701,703,704,706,708,709,710,712,714,715,717,718,720,721,723,725,726,728,730,731,733,734,736,737,739,741,743,744,746,748,750,751,753,755,756,758,760,762,764,765,767,769,771,772,774,776,778,780,781,783,785,787,789,791,793,794,797,798,800,803,805,807,809,811,812,815,816,819,821,823,825,827,829,831,833,835,837,839,841,843,846,848,850,852,854,856,859,861,863,865,868,870,872,874,877,879,882,884,886,889,891,893,896,898,901,903,906,908,910,913,916,918,921,923,926,928,931,934,937,939,942,945,948,950,953,956,959,961,964,967,970,973,976,978,981,985,987,990,993,996,999,1002,1005,1008,1011,1014,1018,1021,1024,1027,1030,1034,1037,1041,1044,1047,1051,1055,1058,1061,1065,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1068,1069,1068,1068,1068,1069,1068,1068 7,880,882,884,885,887,889,890,892,893,895,897,898,900,902,904,906,907,908,910,912,913,915,917,919,921,923,924,926,928,929,932,933,935,937,939,941,942,944,946,948,950,951,953,955,957,959,961,963,965,967,969,971,973,975,977,979,981,983,985,987,989,991,993,995,997,999,1001,1004,1005,1008,1010,1012,1014,1016,1019,1021,1023,1025,1027,1029,1032,1034,1036,1039,1041,1043,1045,1048,1050,1053,1055,1057,1060,1062,1064,1067,1069,1072,1074,1077,1079,1082,1084,1087,1089,1092,1094,1097,1100,1102,1104,1107,1109,1112,1115,1118,1120,1123,1126,1128,1131,1134,1137,1140,1142,1145,1148,1151,1154,1157,1159,1162,1165,1167,1170,1173,1176,1179,1181,1185,1187,1191,1193,1197,1199,1202,1206,1209,1212,1215,1218,1221,1225,1228,1230,1234,1237,1240,1244,1247,1251,1254,1257,1260,1264,1267,1270,1274,1277,1280,1284,1287,1291,1295,1298,1302,1305,1309,1312,1316,1320,1323,1327,1331,1335,1339,1342,1346,1350,1354,1357,1362,1366,1370,1374,1378,1382,1386,1390,1394,1399,1402,1407,1410,1415,1419,1423,1428,1431,1436,1441,1446,1450,1454,1460,1464,1469,1473,1478,1483,1488,1493,1497,1502,1507,1507,1507,1507,1507,1507,1507,1507,1507,1507,1508,1507,1507,1507,1507,1507,1508,1507,1507,1507,1507,1507,1507,1507,1507,1507,1507,1507,1507,1507,1507,1507 8,1251,1253,1255,1257,1260,1262,1264,1267,1269,1271,1274,1276,1278,1280,1283,1285,1287,1290,1293,1295,1297,1300,1302,1304,1307,1310,1312,1315,1317,1320,1322,1324,1327,1330,1332,1334,1338,1340,1342,1345,1348,1350,1353,1355,1358,1361,1364,1366,1369,1372,1374,1377,1379,1382,1385,1388,1391,1393,1396,1399,1402,1405,1408,1410,1413,1416,1419,1422,1425,1428,1431,1435,1437,1441,1443,1446,1449,1453,1456,1459,1462,1465,1468,1471,1475,1478,1481,1485,1488,1490,1494,1498,1501,1505,1508,1511,1514,1518,1522,1525,1528,1531,1535,1538,1542,1546,1548,1552,1556,1560,1563,1566,1570,1574,1578,1582,1585,1589,1593,1597,1601,1604,1608,1612,1616,1620,1624,1628,1632,1636,1640,1644,1648,1651,1656,1659,1663,1667,1671,1676,1680,1683,1688,1691,1695,1700,1704,1709,1714,1717,1722,1726,1731,1735,1740,1744,1749,1754,1758,1762,1767,1772,1776,1781,1785,1790,1795,1800,1804,1809,1814,1818,1823,1828,1833,1838,1843,1848,1854,1858,1863,1869,1874,1879,1885,1890,1896,1901,1907,1913,1918,1924,1929,1935,1940,1945,1950,1956,1962,1968,1973,1979,1985,1991,1997,2002,2009,2014,2020,2026,2033,2039,2045,2052,2059,2065,2071,2079,2085,2092,2098,2105,2111,2119,2125,2126,2126,2126,2126,2125,2126,2126,2126,2126,2126,2125,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126,2126 9,1804,1807,1811,1814,1816,1820,1824,1827,1830,1833,1837,1840,1843,1847,1850,1853,1856,1860,1863,1867,1870,1873,1877,1880,1884,1888,1891,1895,1899,1901,1905,1909,1912,1916,1919,1923,1926,1930,1933,1938,1940,1945,1948,1952,1956,1959,1963,1967,1971,1975,1979,1982,1986,1990,1994,1998,2002,2006,2010,2013,2018,2022,2026,2029,2034,2038,2042,2046,2050,2055,2059,2063,2067,2071,2075,2080,2084,2089,2093,2098,2102,2106,2111,2115,2121,2125,2129,2134,2139,2143,2148,2153,2158,2163,2168,2172,2177,2182,2187,2191,2197,2201,2206,2211,2215,2221,2226,2230,2236,2241,2245,2250,2256,2261,2267,2272,2277,2282,2288,2292,2298,2303,2310,2315,2320,2326,2330,2337,2342,2348,2354,2358,2364,2370,2375,2380,2386,2393,2398,2403,2409,2415,2420,2427,2433,2439,2445,2451,2457,2463,2469,2475,2481,2488,2494,2501,2507,2514,2520,2526,2533,2539,2545,2552,2559,2565,2572,2580,2586,2592,2599,2606,2612,2619,2626,2633,2639,2647,2654,2662,2669,2677,2684,2692,2699,2707,2715,2722,2730,2738,2746,2755,2763,2769,2777,2785,2793,2801,2809,2816,2824,2833,2841,2848,2856,2864,2873,2881,2889,2899,2908,2917,2925,2935,2945,2954,2963,2972,2983,2992,3001,3011,3021,3031,3041,3040,3040,3041,3041,3040,3040,3041,3041,3040,3039,3041,3041,3040,3040,3040,3040,3040,3041,3040,3040,3040,3041,3041,3040,3040,3040,3041,3040,3041,3041,3040 10,2600,2605,2609,2613,2618,2622,2627,2632,2637,2641,2646,2650,2654,2659,2664,2667,2673,2678,2682,2687,2692,2698,2702,2707,2711,2717,2722,2727,2731,2737,2741,2747,2753,2757,2762,2768,2774,2777,2782,2788,2793,2799,2805,2808,2814,2819,2824,2829,2834,2840,2845,2851,2855,2861,2866,2873,2878,2884,2890,2895,2900,2906,2912,2918,2924,2929,2935,2940,2947,2954,2958,2964,2970,2976,2982,2988,2995,3000,3006,3012,3018,3025,3031,3039,3045,3051,3058,3065,3071,3077,3084,3091,3097,3105,3112,3118,3125,3131,3138,3145,3151,3158,3165,3172,3178,3186,3192,3200,3205,3212,3220,3227,3234,3242,3249,3257,3265,3273,3280,3288,3295,3303,3310,3319,3327,3335,3343,3351,3359,3365,3374,3382,3389,3397,3405,3413,3421,3428,3436,3443,3452,3460,3467,3476,3484,3493,3502,3510,3518,3527,3536,3544,3555,3563,3572,3581,3590,3599,3608,3617,3627,3636,3645,3653,3663,3672,3682,3691,3700,3711,3719,3729,3738,3748,3757,3767,3776,3788,3797,3809,3818,3830,3840,3850,3863,3873,3885,3895,3907,3919,3930,3941,3953,3963,3973,3984,3996,4007,4017,4029,4040,4051,4061,4074,4085,4097,4108,4119,4132,4144,4157,4172,4184,4197,4210,4224,4238,4251,4265,4277,4293,4308,4322,4337,4350,4350,4350,4350,4350,4350,4350,4350,4349,4349,4349,4349,4349,4349,4349,4349,4349,4349,4350,4350,4351,4349,4350,4350,4350,4350,4349,4349,4350,4349,4350,4350 11,3295,3300,3306,3312,3318,3324,3330,3335,3341,3347,3353,3359,3365,3371,3377,3383,3389,3395,3401,3407,3414,3420,3428,3433,3439,3445,3451,3459,3464,3472,3478,3484,3491,3497,3504,3510,3516,3523,3529,3536,3543,3550,3556,3563,3569,3577,3583,3590,3597,3604,3611,3618,3625,3633,3639,3647,3654,3661,3668,3675,3682,3690,3698,3705,3712,3721,3728,3735,3743,3750,3758,3765,3772,3780,3787,3797,3805,3812,3819,3828,3836,3843,3852,3860,3869,3877,3885,3895,3903,3912,3921,3929,3938,3945,3956,3965,3972,3981,3990,3998,4008,4016,4025,4034,4042,4052,4060,4070,4078,4087,4096,4106,4115,4125,4136,4145,4155,4164,4174,4186,4195,4205,4214,4225,4236,4245,4256,4267,4277,4287,4298,4307,4317,4326,4337,4347,4357,4368,4377,4387,4397,4407,4419,4429,4440,4451,4462,4474,4486,4496,4508,4520,4529,4542,4554,4565,4577,4589,4601,4612,4624,4636,4647,4659,4671,4682,4697,4707,4719,4730,4743,4756,4768,4780,4792,4805,4817,4831,4845,4859,4873,4888,4902,4915,4929,4944,4958,4973,4987,5002,5017,5032,5046,5062,5074,5089,5104,5118,5131,5145,5162,5175,5190,5204,5220,5235,5250,5264,5280,5299,5313,5331,5348,5366,5384,5401,5418,5436,5455,5472,5492,5509,5527,5547,5565,5565,5565,5567,5566,5566,5565,5566,5564,5565,5566,5567,5566,5565,5565,5565,5565,5566,5564,5565,5566,5566,5565,5565,5565,5565,5566,5567,5565,5565,5565,5566 12,4526,4535,4542,4549,4557,4564,4572,4580,4588,4596,4605,4612,4620,4629,4636,4645,4652,4661,4669,4676,4686,4693,4703,4713,4721,4729,4740,4746,4755,4764,4773,4781,4791,4799,4807,4816,4825,4835,4843,4852,4860,4869,4879,4887,4897,4906,4915,4923,4932,4943,4953,4963,4972,4982,4991,5001,5011,5021,5029,5040,5049,5059,5069,5079,5090,5101,5109,5120,5130,5140,5150,5159,5171,5181,5191,5200,5211,5223,5231,5243,5253,5265,5277,5287,5300,5310,5322,5334,5346,5356,5369,5380,5392,5404,5416,5429,5439,5452,5464,5475,5487,5497,5508,5522,5534,5545,5557,5570,5581,5594,5605,5617,5629,5643,5655,5670,5682,5696,5710,5724,5737,5751,5765,5779,5794,5807,5820,5835,5848,5862,5876,5889,5903,5916,5929,5943,5957,5972,5986,5998,6012,6026,6042,6054,6068,6083,6099,6113,6129,6146,6162,6176,6193,6210,6224,6241,6256,6274,6289,6306,6322,6336,6353,6367,6384,6401,6416,6431,6447,6465,6480,6496,6513,6530,6546,6562,6580,6597,6616,6635,6654,6674,6694,6712,6731,6751,6772,6789,6812,6831,6853,6872,6890,6911,6930,6947,6967,6987,7004,7023,7044,7064,7082,7102,7124,7144,7162,7183,7201,7224,7250,7272,7296,7318,7343,7367,7392,7415,7441,7465,7492,7516,7541,7567,7591,7592,7592,7594,7592,7591,7593,7593,7592,7591,7592,7592,7591,7591,7591,7591,7592,7592,7592,7591,7591,7592,7590,7591,7591,7591,7590,7591,7590,7591,7590,7590 13,6160,6170,6181,6192,6200,6212,6222,6232,6243,6253,6265,6275,6286,6297,6307,6318,6328,6340,6351,6362,6374,6385,6396,6408,6420,6432,6444,6454,6467,6479,6491,6503,6517,6527,6538,6549,6562,6572,6583,6595,6607,6618,6630,6642,6655,6666,6678,6688,6702,6715,6726,6740,6753,6766,6780,6793,6805,6818,6832,6845,6859,6873,6886,6899,6913,6926,6938,6952,6963,6977,6990,7005,7017,7031,7045,7058,7073,7086,7099,7112,7127,7141,7155,7171,7186,7202,7217,7232,7248,7262,7280,7295,7310,7327,7343,7358,7374,7388,7403,7419,7434,7449,7463,7479,7495,7511,7527,7542,7558,7573,7588,7602,7620,7636,7656,7674,7692,7711,7727,7746,7764,7783,7803,7817,7837,7856,7873,7891,7910,7929,7947,7962,7981,7998,8016,8034,8050,8068,8086,8105,8122,8143,8160,8177,8196,8216,8236,8257,8279,8299,8318,8340,8360,8383,8404,8425,8448,8467,8489,8510,8533,8552,8573,8595,8615,8637,8657,8677,8700,8723,8740,8764,8785,8806,8828,8850,8874,8896,8922,8949,8975,8999,9024,9051,9078,9105,9134,9157,9184,9210,9240,9268,9295,9317,9344,9369,9393,9419,9443,9469,9496,9520,9546,9573,9599,9627,9651,9683,9709,9737,9769,9802,9835,9866,9900,9934,9964,9998,10032,10065,10099,10135,10168,10202,10241,10238,10238,10240,10238,10236,10238,10238,10233,10235,10237,10235,10236,10234,10236,10235,10236,10235,10234,10234,10234,10236,10234,10236,10234,10235,10234,10236,10236,10236,10235,10236 14,8858,8873,8890,8902,8919,8932,8947,8963,8975,8993,9008,9024,9039,9054,9069,9083,9099,9114,9130,9145,9162,9179,9195,9211,9228,9243,9260,9279,9297,9313,9327,9344,9364,9378,9395,9411,9429,9443,9461,9478,9492,9510,9527,9544,9561,9579,9597,9612,9630,9648,9666,9684,9703,9723,9741,9759,9779,9799,9817,9835,9855,9872,9895,9915,9933,9950,9970,9989,10009,10024,10045,10064,10083,10101,10122,10145,10164,10182,10201,10221,10241,10263,10283,10307,10332,10350,10374,10397,10419,10441,10461,10490,10511,10535,10554,10578,10600,10624,10645,10665,10686,10708,10729,10751,10778,10795,10822,10842,10864,10887,10909,10932,10952,10977,11002,11029,11053,11080,11105,11132,11159,11185,11212,11239,11266,11293,11318,11346,11373,11399,11423,11448,11475,11499,11523,11549,11576,11601,11627,11653,11679,11704,11729,11756,11782,11815,11842,11871,11903,11934,11964,11994,12028,12054,12084,12116,12148,12179,12211,12242,12274,12301,12331,12361,12388,12420,12449,12481,12512,12542,12570,12603,12637,12664,12696,12727,12756,12795,12830,12866,12904,12944,12981,13017,13059,13092,13131,13168,13209,13248,13287,13330,13368,13402,13438,13474,13512,13546,13582,13619,13653,13690,13727,13764,13802,13840,13879,13914,13954,13998,14045,14089,14137,14187,14232,14280,14326,14375,14422,14472,14520,14570,14621,14669,14718,14719,14720,14720,14720,14721,14719,14717,14719,14718,14719,14717,14721,14719,14717,14721,14720,14719,14720,14720,14723,14720,14719,14719,14718,14721,14720,14725,14720,14720,14719,14720 15,12231,12249,12269,12286,12308,12331,12347,12367,12385,12407,12422,12445,12465,12485,12505,12524,12545,12565,12589,12610,12631,12653,12680,12698,12718,12741,12767,12782,12809,12831,12853,12874,12898,12920,12944,12963,12986,13005,13028,13051,13067,13093,13113,13136,13160,13182,13201,13224,13247,13272,13298,13321,13349,13370,13396,13422,13445,13472,13498,13523,13549,13575,13597,13625,13652,13675,13702,13725,13746,13771,13796,13820,13845,13867,13890,13918,13941,13968,13992,14018,14044,14072,14102,14131,14160,14186,14215,14245,14274,14305,14331,14363,14393,14423,14451,14483,14513,14543,14569,14597,14623,14649,14675,14706,14734,14762,14787,14819,14845,14875,14905,14930,14961,14992,15027,15060,15093,15125,15162,15196,15230,15267,15300,15337,15374,15408,15441,15475,15511,15549,15576,15607,15644,15673,15706,15739,15770,15804,15840,15872,15908,15941,15975,16007,16043,16082,16121,16162,16197,16238,16279,16316,16355,16401,16435,16476,16519,16557,16600,16644,16683,16721,16758,16797,16833,16872,16913,16953,16987,17031,17072,17111,17147,17188,17227,17269,17312,17359,17408,17458,17509,17555,17602,17656,17706,17757,17808,17860,17909,17962,18017,18068,18121,18169,18218,18261,18308,18351,18401,18450,18500,18548,18598,18643,18693,18745,18793,18842,18897,18955,19016,19075,19141,19202,19264,19327,19386,19456,19520,19584,19651,19720,19786,19852,19922,19923,19921,19921,19921,19922,19920,19921,19926,19918,19920,19922,19917,19919,19919,19919,19920,19919,19917,19920,19918,19919,19919,19920,19917,19923,19921,19919,19920,19921,19919,19922
     
    main.c

    #include "msp430g2211.h" void putc(unsigned); // serial_tx.asm void puts(char *); // serial_tx.asm void utoa(unsigned, char *); // utoa.asm static char s[8]; // buffer for printing unsigned int /* Freq = Count / Time Freq = Count / (100 / 32768) <-- 100 cycles of 32.768 kHz clock Freq (kHz) = Count / ((100 / 32768) * 1000) Freq (kHz) = Count / 3.0517578125 Freq (kHz) = Count * (1 / 3.0517578125) Freq (kHz) = Count * 0.32768 Freq (kHz) ~= (Count * 21475) / 65536 Freq (kHz) ~= (Count * 21475) >> 16 Freq (kHz) ~= ((Count * 21475) + 32768) >> 16 <-- Better rounding */ void show_cal(char *n, unsigned char *c) // Show info memory data for factory calibrated clock { // puts(n); putc(','); // Name utoa(((unsigned)*(c + 1))&0x0F, s); // RSEL puts(s); putc(','); // utoa((unsigned)*c, s); // DCO puts(s); puts("\r\n"); // } // void main(void) // { // unsigned n; // unsigned long freq; // char *vs; // // WDTCTL = WDTPW | WDTHOLD; // Disable watchdog reset // TACTL = TASSEL_2; // SMCLK (DCO) // P1DIR = BIT1; // P1OUT = BIT1; // // BCSCTL3 = XCAP_2; // 10 pF n = 0; // do { // - Wait for MSP430 to detect clock is stable IFG1 &= ~OFIFG; // Clear OFIFG while(--n); // Wait a while } while(IFG1 & OFIFG); // Loop until OFIFG remains cleared BCSCTL2 = SELM1 | SELM0; // - Use LFXT1CLK (32 kHz xtal) as clock source // DCOCTL = 0; // Begin with lowest possible DCO clock BCSCTL1 = 0; // // puts("\r\nDCO Characterization\r\n"); // // show_cal("1 MHz", (unsigned char *)0x10FE); // Show factory cals show_cal("8 MHz", (unsigned char *)0x10FC); // show_cal("12 MHz", (unsigned char *)0x10FA);// show_cal("16 MHz", (unsigned char *)0x10F8);// // putc(','); // Labels for X axis for(n = 0; n < 256; ++n) { // 0 to 255 utoa(n, s); // puts(s); // putc(','); // } // puts("\r\n"); // // for(; { // if(DCOCTL == 0) { // Row label (RSEL) if(BCSCTL1 == 16) break; // Done with all? utoa(BCSCTL1 & 0x0F, s); // puts(s); // putc(','); // } // // TACTL |= TACLR; // Clear TimerA TACTL |= MC_2; // Start counting - TimerA continuous mode __delay_cycles(100 - 5); // 100 cycles (5 overhead from previous and next instructions) TACTL &= ~MC_2; // Stop counting - TimerA stop mode // freq = TAR; // Get cycle count // freq = ((freq * 21475) + 32768) >> 16; // Scale to kHz // if(++DCOCTL) { // Next DCOCTL (DCOx/MODx) vs = ","; // } else { // DCOCTL rolled over ++BCSCTL1; // Next RSELx vs = "\r\n"; // End of line } // // utoa((unsigned)freq, s); // Print it, allow time for new DCO freq to settle puts(s); // puts(vs); // } // // puts("Done\r\n"); // // for(;; // } //
     
    serial_tx.asm

    .cdecls C, LIST, "msp430g2211.h" .text .def putc, puts ; 32768 Hz / 2400 bps = 13.6533 cycles per bit ~= 41 cycles per 3 bits (14 / 13 / 14) ; Char to tx in R12 putc: or #0x0100, R12 ; Stop bit mov #0x02, R15 ; Serial out bitmask jmp bit_start ; ; bit0: jmp $ + 2 ; jmp $ + 2 ; nop ; rra R12 ; Bit 0/3/6 jc bit0h ; bic.b R15, &P1OUT ; 14/55/96 jmp bit1 ; bit0h: bis.b R15, &P1OUT ; 14/55/96 jmp bit1 ; ; bit1: jmp $ + 2 ; jmp $ + 2 ; rra R12 ; Bit 1/4/7 jc bit1h ; bic.b R15, &P1OUT ; 27/68/109 jmp bit2 ; bit1h: bis.b R15, &P1OUT ; 27/68/109 jmp bit2 ; ; bit2: jmp $ + 2 ; jmp $ + 2 ; nop ; rra R12 ; Bit Start/2/5/Stop jc bit2h ; bit_start: bic.b R15, &P1OUT ; 0/41/82/- jmp bit0 ; bit2h: bis.b R15, &P1OUT ; -/41/82/123 jne bit0 ; ret_ins: ret puts: ; Tx string using putc mov R12, R14 ; String pointer in R12, copy to R14 putsloop: ; mov.b @R14+, R12 ; Get a byte, inc pointer tst.b R12 ; Test if end of string jz ret_ins ; Yes, exit... call #putc ; Call putc jmp putsloop ; ; .end ;
     
    utoa.asm

    .cdecls C, LIST, "msp430g2211.h" .text .def utoa utoa: ; --- Unsigned to ASCII --- ; - Range 0 to 65535 ; - Leading zeros supressed push R10 ; clr R14 ; Clear packed BCD .loop 13 ; Do 13 bits rla R12 ; Get bit 15 to 3 of binary dadd R14, R14 ; Multiply BCD by 2 and add binary bit .endloop ; clr R15 ; Clear digit 1 of packed BCD .loop 3 ; Do 3 bits rla R12 ; Get bit 2 to 0 of binary dadd R14, R14 ; Multiply BCD by 2 and add binary bit dadd R15, R15 ; .endloop ; swpb R14 ; Swap digit order mov R14, R12 ; Copy packed BCD digits and #0x0F0F, R12 ; Mask digits 5 & 3 rra R14 ; Shift digits 4 & 2 to lower nibble rra R14 ; rra R14 ; rra R14 ; and #0x0F0F, R14 ; Mask digits 4 & 2 mov #('0' << 8) | '0', R10 ; Make ASCII add R10, R12 ; add R10, R14 ; add R10, R15 ; cmp.b R10, R15 ; Is first digit a 0? jne dig5 ; No... cmp.b R10, R14 ; Is second digit a 0? jne dig4 ; No, only the first... cmp.b R10, R12 ; Is third digit a 0? jne dig3 ; No, only the first two... cmp R10, R14 ; Is fourth digit a 0? (second is zero) jne dig2 ; No, only the first three... dig1: ; First four digits are all 0 swpb R12 ; Fifth digit to string mov.b R12, 0(R13) ; inc R13 ; clr.b 0(R13) ; NULL terminate string pop R10 ; ret ; Return ; dig5: ; mov.b R15, 0(R13) ; First digit to string inc R13 ; dig4: ; mov.b R14, 0(R13) ; Second digit to string inc R13 ; dig3: ; mov.b R12, 0(R13) ; Third digit to string inc R13 ; dig2: ; swpb R14 ; Fourth digit to string mov.b R14, 0(R13) ; inc R13 ; jmp dig1 ;
  19. Like
    zeke got a reaction from SystemLevel in msp430bt5190 + pan1315/1325   
    Have you discovered the Bluetooth for MSP430 Wiki?
     
    It's your complete source of msp430 bluetoothy information. And it's free!
     
    Check it out. I'm sure you'll find what you're looking for there.
     
    Let us know how it goes eh? :thumbup:
  20. Like
    zeke reacted to cde in Bit bang I2C master?   
    If I can code an i2c master, so could you. With the usi/usci it's pretty straight forward for master, even bitbanging a master is simple.
     
    In your case, I'm assuming both the original master and the sensor cannot be changed? How much do you know about the master?
    I'm also assuming that the sensor is read like an eeprom.

    Start Master writes slave bus address + w bit. Slave acks. Master writes data address. Slave acks (Re)start Master writes slave bus address + r bit Slave acks Slave transmits 1st bit Master acks Slave transmits 2nd bit Master nacks Stop
    If so, bit bang the sensor, and use the usi/usci eeprom slave example from TI to read back to the master.
    Biggest concern is simply how often the master reads the slave, and ensuring your code is up to the timing of the master. Is the master i2c running at 100khz, 400khz or faster? 100 and 400 is easy enough.
    The other concern is how you code the interrupts and how the master handles missed replies. If you are in the middle of reading the sensor, and the interrupt from the master triggers, is the sensor going to like a hung session and can you reset it? Did you ensure that saving the data from the slave did not get interrupted, corrupting what you would send to the master?
    Or how does the master react to ignored sessions? Can you stretch the clock on the master to be able to read and translate the sensor readings?
     
    Not sure how math intensive the translating you need is, but the g2553 is good enough to do two i2c and I'm sure more than enough for what you have in mind.
  21. Like
    zeke reacted to nuetron in Bit bang I2C master?   
    RobG's bitbanged I2C thread
    Alittle expensive on the ram end, but it works.
  22. Like
    zeke reacted to larsie in Bit bang I2C master?   
    My lcd project on github has som bitbang and hardware i2c code, if its helpful. May not bereadable. Used hw i2c first, then moved to bitbang. Only one way though.
     
    https://github.com/mobilars/LarsLCD
  23. Like
    zeke reacted to gordon in Serial EEPROM   
    http://web.archive.org/web/201004030755 ... index.html
  24. Like
    zeke got a reaction from microcozmoz in Best information for those new to the MSP430?   
    So, now you got a job doing hardware design and you want to use the MSP430 in your design.
     
    But you've discovered that your boss has insisted on using this "wicked cool awesome" and ancient 5V sensor because they have a bazillion in stock.
     
    "What's the problem with that?" you ask.
     
    The problem is this: the MSP430 is a 3.6V device and it doesn't have 5V tolerant I/O's. This means that you'll probably hurt the part if you put 5V into an input. Go ahead and google it. You'll find our very own OCY schooling someone on this topic back in 2008. I'll let you find the article. OCY is shy. And he's probably gonna rip me open for giving away his secret identity.
     
    So, what's the answer? SLAA148 is the answer.
     
    It will take you through the various input and output scenarios that you may face trying to interface to higher voltage systems - not just 5V.
     
    Using this information, you should be able to measure the status of a 12V power supply with the A/D inputs or figure out how to drive a 12V relay.
     
    Have a read. It's useful info.
  25. Like
    zeke got a reaction from Rei Vilo in Best information for those new to the MSP430?   
    If you are new to the MSP430 then you're probably drowning in information right now.

    It's true that there are a zillion configurations to make before the 430 will do what you want it do do.

    So I'm betting that you are asking yourself "Where do I start?"

    I humbly suggest the following TI application notes and books that will get you going in the right direction:

    1. slaa294: MSP430 Software Coding Techniques

    This application report covers software techniques and topics of interest to all MSP430
    programmers. The first part of the document discusses the MSP430 standard
    interrupt-based code flow model, recommended for the vast majority of applications.
    The next part discusses a handful of techniques that should be considered by any
    developer that sets out to develop an MSP430 application. Using these methods can
    greatly reduce debug time and/or provide additional robustness in the field. They
    include initialization procedures, validation of supply rails before performing
    voltage-sensitive operations, and use of special functions. Code examples are
    provided.

    2. : MSP430 32-kHz Crystal OscillatorsSelection of the right crystal, correct load circuit, and proper board layout are importantfor a stable crystal oscillator. This application report summarizes crystal oscillatorfunction and explains the parameters to select the correct crystal for MSP430ultralow-power operation. In addition, hints and examples for correct board layout aregiven. The document also contains detailed information on the possible oscillator teststo ensure stable oscillator operation in mass production.
    3. MSP430 Microcontroller Basics by John H. Davies

    The best thing I can say about this book at this time is that it describes well how to make use of the clocking system of the MSP430. This book should be in your personal library or at least on your wishlist.

    Once you digest the information above then you will be in good shape for success in working with the msp430.

    Have something to add?
    Then post up your valuable sources of knowledge.
×
×
  • Create New...