Jump to content
43oh

tripwire

Members
  • Content Count

    193
  • Joined

  • Last visited

  • Days Won

    14

Reputation Activity

  1. Like
    tripwire reacted to oPossum in Game of Life with G2211   
    // main.c #include "msp430g2211.h" #include "string.h" void video_init(void); unsigned pix[14], nxt[14]; unsigned get_pix(int x, int y) { if(x < 0 || x > 15 || y < 0 || y > 13) return 0; return (pix[y] >> x) & 1; } void main(void) { int x, y, n; WDTCTL = WDTPW + WDTHOLD; // No watchdog BCSCTL1 = XT2OFF + 15; // DCO 16 Mhz DCOCTL = 0x86; // // P1DIR = 0xF2; // I/O assignment P1REN = 0x0D; // Pull up resistor P1OUT = 0x0F; // P1SEL = 0x50; // Enable Timer A output, SMCLK output video_init(); // Begin video generation // Initial GOL field pix[0] = pix[2] = pix[4] = pix[6] = pix[8] = pix[10] = pix[12] = 0x5555; pix[1] = pix[3] = pix[5] = pix[7] = pix[9] = pix[11] = pix[13] = 0xAAAA; pix[0] = 0x0000; pix[1] = 0x000E; pix[2] = 0x0000; pix[3] = 0; memcpy(nxt, pix, sizeof(nxt)); for(; { for(y = 0; y < 14; ++y) { for(x = 0; x < 16; ++x) { n = get_pix(x - 1, y - 1) + get_pix(x , y - 1) + get_pix(x + 1, y - 1) + get_pix(x - 1, y ) + /* me */ get_pix(x + 1, y ) + get_pix(x - 1, y + 1) + get_pix(x , y + 1) + get_pix(x + 1, y + 1); if(get_pix(x, y)) { if(n < 2 || n > 3) nxt[y] &= ~(1 << x); } else { if(n == 3) nxt[y] |= (1 << x); } } } __delay_cycles(5000000); memcpy(pix, nxt, sizeof(pix)); } }

    ; video.asm .cdecls C, LIST, "msp430g2211.h" .text .global video_init .global pix .bss sync_state, 2 .bss sync_lines, 2 .bss video_state, 2 .bss vid_line, 2 video_init ; --- Initialize Video Generation --- clr &sync_state ; Init state machine mov #1, sync_lines ; clr &video_state ; mov #1016, &TACCR0 ; Setup Timer A period for 63.5 us mov #75, &TACCR1 ; Setup Timer A compare for video sync mov #0x0210, &TACTL ; Timer A config: SMCLK, count up mov #0x0060, &TACCTL1 ; Setup Timer A set/reset output mode bis #0x0010, &TACCTL0 ; Enable PWM interupt eint ; Enable interupts ret ; ; video_isr ; --- Video ISR --- dec &sync_lines ; Decrement sync lines jne vid_state ; Skip sync if not zero... add &sync_state, PC ; Jump to sync handler... ; - Field 1/3 jmp vid_eq ; Pre Equalizing jmp vid_vsync ; Vertical Sync jmp vid_eq ; Post Equalizing jmp vid_vbi ; VBI jmp vid_blank_9 ; 9 blank lines jmp vid_active ; Active Video jmp vid_blank_9 ; 9 blank lines jmp vid_half ; Video half line ; - Field 2/4 jmp vid_eq ; Pre Equalizing jmp vid_vsync ; Vertical Sync jmp vid_eq ; Post Equalizing jmp vid_half ; Video half line jmp vid_vbi ; VBI jmp vid_blank_9 ; 9 blank lines jmp vid_active ; Active Video jmp vid_blank_9l ; 9 blank lines vid_state ; -- Active Video Generation add &video_state, PC ; reti ; No active video jmp vid_field ; Field ; vid_eq ; Equalizing pulses - 6 half lines mov #508, &TACCR0 ; Half line mov #38, &TACCR1 ; Equalizing pulse duration mov #6, &sync_lines ; 6 half lines clr &video_state ; No video generation during sync incd &sync_state ; Next state reti ; ; vid_vsync ; Vertical sync - 6 half lines mov #508 - 75, &TACCR1 ; Sync pulse duration mov #6, &sync_lines ; 6 half lines incd &sync_state ; Next state reti ; ; vid_half ; Video half line - 1 half line mov #508, &TACCR0 ; Half line mov #75, &TACCR1 ; Sync pulse duration mov #1, &sync_lines ; 1 half line incd &sync_state ; Next state clr &video_state ; No video generation during half line and sync reti ; ; vid_vbi ; Vertical blanking interval - 11 lines mov #1016, &TACCR0 ; Full line mov #75, &TACCR1 ; Sync pulse duration mov #11, &sync_lines ; 11 lines incd &sync_state ; Next state reti ; ; vid_active ; Active video - 224 lines mov #224, &sync_lines ; 224 lines incd &sync_state ; Next state mov #2, &video_state ; Genearte video clr &vid_line ; Clear video line count jmp vid_field ; Generate video... ; vid_blank_9 ; 9 blank lines mov #9, &sync_lines ; incd &sync_state ; clr &video_state ; reti ; ; vid_blank_9l ; 9 blank lines (last in field) mov #9, &sync_lines ; clr &sync_state ; clr &video_state ; reti ; ; vid_field ; push R10 ; push R12 ; push R14 ; ; mov &TAR, R10 ; cmp #176, R10 ; jlo $ - 8 ; and #7, R10 ; rla R10 ; add R10, PC ; nop ; nop ; nop ; nop ; nop ; nop ; nop ; ; mov &vid_line, R12 ; inc &vid_line ; rra R12 ; rra R12 ; rra R12 ; ;bic #1, R12 ; add #pix, R12 ; mov @R12, R12 ; mov #16, R14 ; pixloop rlc R12 ; jc pixon ; bic.b #0x80, &P1OUT ; jmp nexpix ; pixon bis.b #0x80, &P1OUT ; jmp nexpix ; nexpix mov #10, R10 ; dec R10 ; jne $ - 2 ; dec R14 ; jne pixloop ; nop ; nop ; nop ; bic.b #0x80, &P1OUT ; ; pop R14 ; pop R12 ; pop R10 ; ; reti ; ; ; Interrupt Vectors .sect ".int09" ; TACCR0 CCIFG .short video_isr ; ; .end ;

    I can explain the video code if anyone is interested. It is very flexible and does proper interlaced video and sync (equalization and serration).
  2. Like
    tripwire reacted to yosh in GREETINGS   
    For a quick overview and some hints I found THIS useful.
    I guess you should start to find a PCB Layout tool you like (I prefer Diptrace for example) and then start to make small projects first (I assume you know how to get a prototype running on a breadbord or perf board). I normally choose Oshpark or iTead for small batch PCB runs.
  3. Like
    tripwire got a reaction from greeeg in [FIXED!] JTAG interferes with SensorTag external flash access   
    Here's a heads-up for anyone that wants to use the external SPI flash memory on the SensorTag: it's not accessible while a debugger session is active.
     
    Unfortunately the pin on the SensorTag's CC2650 which outputs the SPI clock to the flash memory is also used as the JTAG TDI pin:
     

     
    While you're debugging using the Debug DevPack the CC2650 is unable to clock data out to the flash chip. That means the flash will just sit there doing nothing and the CC2650 will end up reading zeroes from the SPI bus.
     
    To use the flash you need to be certain that no JTAG communication is occurring during execution of your firmware.
     
    The easiest way to do this is just to disconnect the Debug DevPack and power the SensorTag from a coin cell or external power supply.
     
    Alternatively you can use the Debug DevPack to power the SensorTag, but then you have to follow this procedure:
    Load your updated firmware onto the SensorTag using the Debug DevPack (I just run it in the CCS debugger) Terminate the debug session once you reach the start of main() Disconnect the Debug DevPack from USB Detach the SensorTag from the DevPack Connect the Debug DevPack to USB Reattach the SensorTag to the Debug DevPack Be careful not to miss step 2, or the DevPack will resume JTAG communication when everything is connected up again. I found that out the hard way...
     
    Also, the order of the last two steps is to avoid an issue with powering up the Debug DevPack while it's connected to a SensorTag with no coin cell. The advantage of that is that you don't need a coin cell (I've drained two already...)
     
    This makes testing code that uses the flash really difficult, as there's no way to use the debugger. I've been using a combination of UART logging, LED flashes and beep codes from the onboard buzzer to keep track of where the code is up to.
     
    The other thing I'm doing is detecting whether the flash is available during startup and skipping the flash accesses if it's not there. That lets the rest of the code run in the debugger without problems.
     
    The command sequence I'm using to detect the flash is:
    Repeatedly send a Read Status Register command (0x05, 0x00) until the received BUSY flag is clear Send a Read Mode Reset command (0xFF, 0xFF) Send a Release From Power Down command sequence (0xAB, 0x00, 0x00, 0x00, 0x00) Flash is available if the device ID value 0x12 is received in the last byte of the Release From Power Down sequence This sequence is arranged to work irrespective of the state of the flash chip. If JTAG is active the code will immediately fall through step 1 (BUSY flag is zero), but the received device ID at step 4 will be zero too. Step 2 covers against any remote chance that the device has ended up in dual-SPI mode. Step 3 wakes the chip if it has been put in suspend, and returns the device ID regardless.
  4. Like
    tripwire reacted to Fred in The EVIL Pranks!   
    I quite like changing the keyword colour in Visual Studio to the background colour. Start typing and words then mysteriously vanish. Not too hard to work out what's going on, but still fun.
  5. Like
    tripwire reacted to sq7bti in Educational BoosterPack 8 bit FFT Spectrum Analyzer Attempt   
    Hi @@simpleavr,
     
    You might try to hand pick values from wider window, but here are Hamming windows size 16 (mind the symmetry):
    // round(255 * window('kr',16,6)) //const unsigned char hamming[8] = ( 4, 18, 46, 86, 136, 187, 228, 252); //, 252, 228, 187, 136, 86, 46, 18, 4 ); // round(255 * window('kr',16,4)) const unsigned char hamming[8] = ( 23, 51, 88, 130, 172, 210, 238, 253); //, 253, 238, 210, 172, 130, 88, 51, 23 ); // round(255 * window('kr',16,2)) //const unsigned char hamming[8] = ( 112, 141, 170, 196, 218, 236, 248, 254); //, 254, 248, 236, 218, 196, 170, 141, 112 ); More information regarding window function you will find in Scilab help.
     
    S.
  6. Like
    tripwire reacted to D12 in MSP430G2553 Interfacing w/ PS2 Controller   
    Nevermind, main problem was PS2 controllers send LSB first, so instead of sending 0x01, it needs to be sent 0x80.  Other then that minor code tweaks and it works fine.
  7. Like
    tripwire reacted to oPossum in Fraunchpad Synth - Still Alive   
    The note envelope is a simple exponential decay. After each cycle of the waveform, the level is multiplied by 65408/65536 (0.99805). Higher frequency notes will decay faster then lower frequency.

    The music data is in an array in FRAM, it is not MIDI driven like the previous version

    Inspired by this project

    main.c
    #include "msp430fr5739.h" #include "alive.h" void set_tick(unsigned); unsigned get_tick(void); void synth_init(void); void set_note(int, int, int); int wave[257] = { 0, 804, 1608, 2410, 3212, 4011, 4808, 5602, 6393, 7179, 7962, 8739, 9512, 10278, 11039, 11793, 12539, 13279, 14010, 14732, 15446, 16151, 16846, 17530, 18204, 18868, 19519, 20159, 20787, 21403, 22005, 22594, 23170, 23731, 24279, 24811, 25329, 25832, 26319, 26790, 27245, 27683, 28105, 28510, 28898, 29268, 29621, 29956, 30273, 30571, 30852, 31113, 31356, 31580, 31785, 31971, 32137, 32285, 32412, 32521, 32609, 32678, 32728, 32757, 32767, 32757, 32728, 32678, 32609, 32521, 32412, 32285, 32137, 31971, 31785, 31580, 31356, 31113, 30852, 30571, 30273, 29956, 29621, 29268, 28898, 28510, 28105, 27683, 27245, 26790, 26319, 25832, 25329, 24811, 24279, 23731, 23170, 22594, 22005, 21403, 20787, 20159, 19519, 18868, 18204, 17530, 16846, 16151, 15446, 14732, 14010, 13279, 12539, 11793, 11039, 10278, 9512, 8739, 7962, 7179, 6393, 5602, 4808, 4011, 3212, 2410, 1608, 804, 0, -804, -1608, -2410, -3212, -4011, -4808, -5602, -6393, -7179, -7962, -8739, -9512, -10278, -11039, -11793, -12539, -13279, -14010, -14732, -15446, -16151, -16846, -17530, -18204, -18868, -19519, -20159, -20787, -21403, -22005, -22594, -23170, -23731, -24279, -24811, -25329, -25832, -26319, -26790, -27245, -27683, -28105, -28510, -28898, -29268, -29621, -29956, -30273, -30571, -30852, -31113, -31356, -31580, -31785, -31971, -32137, -32285, -32412, -32521, -32609, -32678, -32728, -32757, -32767, -32757, -32728, -32678, -32609, -32521, -32412, -32285, -32137, -31971, -31785, -31580, -31356, -31113, -30852, -30571, -30273, -29956, -29621, -29268, -28898, -28510, -28105, -27683, -27245, -26790, -26319, -25832, -25329, -24811, -24279, -23731, -23170, -22594, -22005, -21403, -20787, -20159, -19519, -18868, -18204, -17530, -16846, -16151, -15446, -14732, -14010, -13279, -12539, -11793, -11039, -10278, -9512, -8739, -7962, -7179, -6393, -5602, -4808, -4011, -3212, -2410, -1608, -804, 0 }; void main(void) { unsigned osc; const struct event_t *e; WDTCTL = WDTPW + WDTHOLD; CSCTL0 = 0xA500; // Unlock clock registers CSCTL1 = DCORSEL | DCOFSEL1 | DCOFSEL0; // 24 MHz CSCTL2 = 0x0333; // Use DCO clock for ACLK, SMCLK and MCLK CSCTL3 = 0x0000; // Set all clock divider to 1 //CSCTL4 = //CSCTL5 = P1DIR = 0x01; // PWM audio output on P1.0 P1REN = 0x00; // P1OUT = 0x00; // P1SEL0 = 0x01; // Enable Timer A output P1SEL1 = 0x00; // P2DIR = 0x00; // P2REN = 0x00; // P2OUT = 0x00; // P2SEL0 = 0x00; // P2SEL1 = 0x03; // Enable UART UCA0 P3DIR = 0x10; // P3REN = 0x00; // P3OUT = 0x00; // P3SEL0 = 0x10; // SMCLK output P3SEL1 = 0x10; // SMCLK output P4DIR = 0x00; // P4REN = 0x00; // P4OUT = 0x00; // P4SEL0 = 0x00; // P4SEL1 = 0x00; // PJDIR = 0x0F; // 4 LEDs PJREN = 0x00; // PJOUT = 0x00; // PJSEL0 = 0x00; // PJSEL1 = 0x00; // UCA0MCTLW = 1; // 16x oversampling UCA0BRW = 24000000 / 16 / 9600; // Fraunchpad UART //UCA0BRW = 24000000 / 16/ 31250; // Standard MIDI bit rate UCA0CTLW0 = 0x0080; // Use SMCLK for bit rate generator, release reset synth_init(); for(osc = 0, e = tune_still_alive; e->pitch; ++e) { set_note(osc++ & 7, e->pitch, 9000); ++PJOUT; set_tick((e[1].time - e[0].time) * 150); while(get_tick()); } }

    alive.h

    struct event_t { unsigned time; unsigned pitch; }; static const struct event_t tune_still_alive[] = { 192, 91, 240, 90, 288, 88, 336, 88, 384, 69, 384, 90, 432, 74, 480, 78, 528, 74, 576, 71, 624, 74, 672, 78, 720, 74, 768, 69, 816, 74, 864, 78, 912, 74, 912, 81, 960, 71, 960, 91, 1008, 74, 1008, 90, 1056, 78, 1056, 88, 1104, 74, 1104, 88, 1152, 69, 1200, 74, 1200, 90, 1248, 78, 1296, 74, 1344, 71, 1344, 86, 1392, 74, 1440, 78, 1440, 88, 1488, 74, 1488, 81, 1536, 69, 1584, 74, 1632, 78, 1680, 74, 1728, 71, 1776, 74, 1824, 78, 1872, 74, 1872, 81, 1920, 71, 1920, 88, 1968, 76, 2016, 79, 2016, 90, 2064, 76, 2064, 91, 2112, 71, 2160, 76, 2208, 79, 2208, 88, 2256, 76, 2256, 85, 2304, 69, 2352, 73, 2352, 86, 2400, 79, 2448, 73, 2496, 69, 2496, 88, 2544, 73, 2592, 79, 2592, 81, 2640, 73, 2640, 81, 2688, 69, 2736, 74, 2736, 90, 2784, 78, 2832, 74, 2880, 71, 2928, 74, 2976, 78, 3024, 74, 3072, 69, 3120, 74, 3168, 78, 3216, 74, 3264, 71, 3264, 91, 3312, 74, 3312, 90, 3360, 78, 3360, 88, 3408, 74, 3408, 88, 3456, 69, 3456, 90, 3504, 74, 3552, 78, 3600, 74, 3648, 71, 3696, 74, 3744, 78, 3792, 74, 3840, 69, 3888, 74, 3936, 78, 3984, 74, 3984, 81, 4032, 71, 4032, 91, 4080, 74, 4080, 90, 4128, 78, 4128, 88, 4176, 74, 4176, 88, 4224, 69, 4272, 74, 4320, 78, 4320, 90, 4368, 74, 4368, 86, 4416, 71, 4464, 74, 4512, 78, 4512, 88, 4560, 74, 4560, 81, 4608, 69, 4656, 74, 4704, 78, 4752, 74, 4800, 71, 4848, 74, 4896, 78, 4944, 74, 4992, 71, 4992, 88, 5040, 76, 5088, 79, 5088, 90, 5136, 76, 5136, 91, 5184, 71, 5232, 76, 5280, 79, 5280, 88, 5328, 76, 5328, 85, 5376, 69, 5424, 73, 5472, 79, 5472, 86, 5520, 73, 5520, 88, 5568, 69, 5616, 73, 5616, 81, 5664, 79, 5664, 86, 5712, 73, 5712, 88, 5760, 70, 5760, 89, 5808, 74, 5808, 88, 5856, 77, 5856, 86, 5904, 81, 5904, 84, 6048, 81, 6096, 82, 6141, 89, 6144, 105, 6144, 72, 6144, 77, 6144, 84, 6192, 81, 6192, 96, 6240, 108, 6240, 72, 6240, 77, 6240, 89, 6288, 96, 6336, 103, 6336, 72, 6336, 76, 6336, 88, 6336, 88, 6384, 79, 6384, 86, 6384, 96, 6432, 108, 6432, 72, 6432, 76, 6432, 86, 6480, 84, 6480, 96, 6528, 106, 6528, 70, 6528, 74, 6528, 86, 6528, 86, 6576, 105, 6576, 82, 6576, 84, 6576, 96, 6624, 103, 6624, 70, 6624, 74, 6624, 84, 6672, 76, 6672, 96, 6720, 105, 6720, 72, 6720, 77, 6720, 84, 6720, 89, 6768, 81, 6768, 96, 6816, 101, 6816, 72, 6816, 77, 6816, 81, 6864, 82, 6864, 96, 6909, 89, 6912, 105, 6912, 72, 6912, 77, 6912, 84, 6960, 81, 6960, 96, 7008, 108, 7008, 72, 7008, 77, 7008, 89, 7056, 96, 7104, 103, 7104, 72, 7104, 76, 7104, 88, 7104, 91, 7152, 79, 7152, 89, 7152, 96, 7200, 108, 7200, 72, 7200, 76, 7200, 88, 7248, 86, 7248, 96, 7296, 106, 7296, 70, 7296, 74, 7296, 86, 7296, 86, 7344, 105, 7344, 82, 7344, 88, 7344, 96, 7392, 103, 7392, 70, 7392, 74, 7392, 89, 7440, 76, 7440, 96, 7488, 105, 7488, 72, 7488, 77, 7488, 89, 7488, 89, 7536, 81, 7536, 96, 7584, 101, 7584, 72, 7584, 77, 7584, 91, 7632, 93, 7632, 96, 7680, 103, 7680, 70, 7680, 74, 7680, 91, 7680, 94, 7728, 106, 7728, 79, 7728, 94, 7776, 105, 7776, 70, 7776, 74, 7776, 93, 7824, 103, 7824, 79, 7872, 100, 7872, 72, 7872, 76, 7872, 91, 7872, 91, 7920, 101, 7920, 79, 7968, 103, 7968, 72, 7968, 76, 7968, 89, 8016, 108, 8016, 79, 8016, 91, 8064, 105, 8064, 72, 8064, 77, 8064, 89, 8064, 93, 8112, 108, 8112, 81, 8112, 93, 8160, 103, 8160, 72, 8160, 77, 8160, 88, 8160, 91, 8208, 108, 8208, 81, 8256, 101, 8256, 74, 8256, 77, 8256, 86, 8256, 89, 8304, 81, 8304, 93, 8352, 105, 8352, 74, 8352, 77, 8352, 86, 8400, 81, 8400, 84, 8445, 89, 8448, 106, 8448, 70, 8448, 74, 8448, 86, 8496, 79, 8496, 89, 8496, 98, 8544, 101, 8544, 70, 8544, 74, 8544, 89, 8592, 79, 8592, 88, 8592, 98, 8640, 105, 8640, 69, 8640, 73, 8640, 88, 8688, 79, 8688, 88, 8688, 97, 8736, 103, 8736, 69, 8736, 73, 8736, 74, 8736, 90, 8784, 102, 8784, 79, 8784, 90, 8832, 62, 8832, 69, 8880, 74, 8928, 78, 8976, 62, 8976, 74, 9024, 59, 9024, 71, 9072, 74, 9120, 78, 9168, 59, 9168, 74, 9216, 62, 9216, 69, 9264, 74, 9312, 78, 9360, 62, 9360, 74, 9408, 59, 9408, 71, 9456, 74, 9504, 78, 9552, 59, 9552, 74, 9600, 62, 9600, 69, 9648, 74, 9696, 78, 9744, 62, 9744, 74, 9792, 59, 9792, 71, 9840, 74, 9888, 78, 9936, 59, 9936, 74, 9984, 62, 9984, 69, 10032, 74, 10080, 78, 10128, 62, 10128, 74, 10128, 81, 10176, 71, 10176, 71, 10176, 91, 10224, 74, 10224, 90, 10272, 71, 10272, 78, 10272, 88, 10320, 69, 10320, 74, 10320, 88, 10368, 62, 10368, 69, 10368, 90, 10416, 74, 10464, 78, 10512, 62, 10512, 74, 10560, 59, 10560, 71, 10608, 74, 10656, 78, 10704, 59, 10704, 74, 10752, 62, 10752, 69, 10800, 74, 10848, 78, 10896, 62, 10896, 74, 10944, 59, 10944, 71, 10944, 91, 10992, 74, 10992, 90, 11040, 78, 11040, 88, 11088, 59, 11088, 74, 11088, 88, 11136, 62, 11136, 69, 11184, 74, 11232, 78, 11232, 90, 11280, 62, 11280, 74, 11280, 86, 11328, 59, 11328, 71, 11376, 74, 11376, 88, 11424, 78, 11472, 59, 11472, 74, 11472, 81, 11520, 62, 11520, 69, 11568, 74, 11616, 78, 11664, 62, 11664, 74, 11712, 59, 11712, 71, 11760, 74, 11808, 78, 11856, 59, 11856, 74, 11904, 64, 11904, 71, 11904, 88, 11952, 76, 12000, 79, 12000, 90, 12048, 64, 12048, 76, 12048, 91, 12096, 64, 12096, 71, 12144, 66, 12144, 76, 12192, 67, 12192, 79, 12192, 88, 12240, 76, 12288, 57, 12288, 69, 12288, 85, 12336, 73, 12384, 79, 12384, 86, 12432, 57, 12432, 73, 12432, 88, 12480, 57, 12480, 69, 12528, 59, 12528, 73, 12576, 61, 12576, 79, 12576, 81, 12624, 73, 12624, 81, 12672, 62, 12672, 69, 12720, 74, 12720, 90, 12768, 78, 12816, 62, 12816, 74, 12864, 59, 12864, 71, 12912, 74, 12960, 78, 13008, 59, 13008, 74, 13056, 62, 13056, 69, 13104, 74, 13152, 78, 13200, 62, 13200, 74, 13200, 81, 13200, 86, 13248, 71, 13248, 71, 13248, 91, 13248, 95, 13296, 74, 13296, 90, 13296, 93, 13344, 71, 13344, 78, 13344, 88, 13344, 91, 13392, 69, 13392, 74, 13392, 88, 13392, 91, 13440, 62, 13440, 69, 13440, 90, 13440, 93, 13488, 74, 13536, 78, 13584, 62, 13584, 74, 13632, 59, 13632, 71, 13680, 74, 13728, 78, 13776, 59, 13776, 74, 13824, 62, 13824, 69, 13872, 74, 13920, 78, 13968, 62, 13968, 74, 13968, 81, 13968, 86, 14016, 59, 14016, 71, 14016, 91, 14016, 95, 14064, 74, 14064, 90, 14064, 93, 14112, 78, 14112, 88, 14112, 91, 14160, 59, 14160, 74, 14160, 88, 14160, 91, 14208, 62, 14208, 69, 14256, 74, 14304, 78, 14304, 90, 14304, 93, 14352, 62, 14352, 74, 14352, 86, 14352, 90, 14400, 59, 14400, 71, 14448, 74, 14496, 78, 14496, 88, 14496, 91, 14544, 59, 14544, 74, 14544, 81, 14544, 86, 14592, 62, 14592, 69, 14640, 74, 14688, 78, 14736, 62, 14736, 74, 14784, 59, 14784, 71, 14832, 74, 14880, 78, 14928, 59, 14928, 74, 14976, 64, 14976, 71, 14976, 88, 15024, 76, 15072, 79, 15072, 90, 15120, 64, 15120, 76, 15120, 91, 15168, 64, 15168, 71, 15216, 66, 15216, 76, 15264, 67, 15264, 79, 15264, 88, 15312, 76, 15360, 57, 15360, 69, 15360, 85, 15408, 73, 15456, 79, 15456, 86, 15504, 57, 15504, 73, 15504, 88, 15552, 57, 15552, 69, 15600, 59, 15600, 73, 15600, 81, 15648, 61, 15648, 79, 15648, 86, 15696, 57, 15696, 73, 15696, 88, 15744, 58, 15744, 70, 15744, 89, 15792, 74, 15792, 88, 15840, 81, 15840, 86, 15888, 70, 15888, 77, 15888, 84, 15936, 81, 15984, 77, 16032, 70, 16032, 77, 16032, 81, 16032, 81, 16080, 57, 16080, 77, 16080, 79, 16080, 82, 16128, 65, 16128, 72, 16128, 77, 16128, 81, 16128, 84, 16176, 81, 16224, 72, 16224, 77, 16224, 84, 16224, 89, 16272, 65, 16320, 60, 16320, 72, 16320, 76, 16320, 84, 16320, 88, 16368, 79, 16368, 86, 16416, 72, 16416, 76, 16416, 82, 16416, 86, 16464, 60, 16464, 81, 16464, 84, 16512, 58, 16512, 70, 16512, 74, 16512, 82, 16512, 86, 16560, 81, 16560, 82, 16560, 84, 16608, 70, 16608, 74, 16608, 81, 16608, 84, 16656, 58, 16656, 76, 16704, 65, 16704, 72, 16704, 77, 16704, 81, 16704, 84, 16752, 81, 16800, 72, 16800, 77, 16800, 79, 16800, 81, 16848, 77, 16848, 82, 16896, 65, 16896, 72, 16896, 77, 16896, 77, 16896, 84, 16944, 81, 16992, 72, 16992, 77, 16992, 81, 16992, 89, 17040, 65, 17088, 60, 17088, 72, 17088, 76, 17088, 82, 17088, 91, 17136, 79, 17136, 81, 17136, 89, 17184, 72, 17184, 76, 17184, 79, 17184, 88, 17232, 60, 17232, 77, 17232, 86, 17280, 58, 17280, 70, 17280, 74, 17280, 77, 17280, 86, 17328, 79, 17328, 82, 17328, 88, 17376, 70, 17376, 74, 17376, 81, 17376, 89, 17424, 58, 17424, 76, 17472, 65, 17472, 72, 17472, 77, 17472, 81, 17472, 89, 17520, 81, 17568, 65, 17568, 72, 17568, 77, 17568, 82, 17568, 91, 17616, 60, 17616, 84, 17616, 93, 17664, 58, 17664, 70, 17664, 74, 17664, 86, 17664, 94, 17712, 79, 17712, 86, 17712, 94, 17760, 58, 17760, 70, 17760, 74, 17760, 84, 17760, 93, 17808, 79, 17856, 60, 17856, 72, 17856, 76, 17856, 84, 17856, 91, 17904, 79, 17952, 60, 17952, 72, 17952, 76, 17952, 81, 17952, 89, 18000, 79, 18000, 82, 18000, 91, 18048, 65, 18048, 72, 18048, 77, 18048, 84, 18048, 93, 18096, 81, 18096, 84, 18096, 93, 18144, 64, 18144, 72, 18144, 77, 18144, 82, 18144, 91, 18192, 81, 18192, 89, 18240, 62, 18240, 74, 18240, 77, 18240, 81, 18240, 89, 18288, 81, 18336, 60, 18336, 74, 18336, 77, 18336, 79, 18336, 86, 18384, 77, 18384, 81, 18384, 84, 18432, 58, 18432, 70, 18432, 74, 18432, 77, 18432, 86, 18480, 79, 18480, 79, 18480, 89, 18528, 65, 18528, 70, 18528, 74, 18528, 81, 18528, 89, 18576, 79, 18576, 79, 18576, 88, 18624, 57, 18624, 69, 18624, 73, 18672, 79, 18672, 79, 18672, 88, 18720, 64, 18720, 69, 18720, 73, 18720, 81, 18720, 90, 18768, 79, 18768, 81, 18768, 90, 18816, 62, 18816, 69, 18864, 74, 18912, 78, 18960, 62, 18960, 74, 19008, 59, 19008, 71, 19056, 74, 19104, 78, 19152, 59, 19152, 74, 19200, 62, 19200, 69, 19248, 74, 19296, 78, 19344, 62, 19344, 74, 19392, 59, 19392, 71, 19440, 74, 19488, 78, 19536, 59, 19536, 74, 19584, 62, 19584, 69, 19632, 74, 19680, 78, 19728, 62, 19728, 74, 19776, 59, 19776, 71, 19824, 74, 19872, 78, 19920, 59, 19920, 74, 19968, 62, 19968, 69, 20016, 74, 20064, 78, 20112, 62, 20112, 74, 20160, 71, 20160, 71, 20160, 91, 20184, 91, 20208, 74, 20208, 90, 20256, 71, 20256, 78, 20256, 88, 20304, 69, 20304, 74, 20304, 88, 20352, 69, 20376, 90, 20400, 74, 20448, 78, 20496, 74, 20544, 71, 20592, 74, 20640, 78, 20688, 74, 20736, 69, 20784, 74, 20832, 78, 20880, 74, 20880, 81, 20928, 71, 20928, 91, 20976, 74, 20976, 90, 21024, 78, 21024, 88, 21072, 74, 21072, 88, 21120, 69, 21168, 74, 21216, 78, 21216, 90, 21264, 74, 21264, 86, 21312, 71, 21360, 74, 21408, 78, 21408, 88, 21456, 74, 21456, 81, 21504, 69, 21552, 74, 21600, 78, 21648, 74, 21696, 71, 21744, 74, 21792, 78, 21840, 74, 21888, 71, 21888, 88, 21936, 76, 21984, 79, 21984, 90, 22032, 76, 22032, 91, 22080, 71, 22128, 76, 22176, 79, 22176, 88, 22224, 76, 22272, 69, 22272, 85, 22320, 73, 22368, 79, 22368, 86, 22416, 73, 22416, 88, 22464, 69, 22512, 73, 22560, 79, 22560, 81, 22608, 73, 22608, 81, 22656, 69, 22704, 74, 22704, 90, 22752, 78, 22800, 74, 22848, 71, 22896, 74, 22944, 78, 22992, 74, 23040, 69, 23088, 74, 23136, 78, 23184, 74, 23232, 71, 23232, 91, 23232, 95, 23280, 74, 23280, 90, 23280, 93, 23328, 78, 23328, 88, 23328, 91, 23376, 74, 23376, 88, 23376, 91, 23424, 62, 23424, 69, 23436, 90, 23436, 93, 23472, 74, 23520, 78, 23568, 62, 23568, 74, 23616, 59, 23616, 71, 23664, 74, 23712, 78, 23760, 59, 23760, 74, 23808, 62, 23808, 69, 23856, 74, 23904, 78, 23952, 62, 23952, 74, 24000, 59, 24000, 71, 24000, 91, 24000, 95, 24048, 74, 24048, 90, 24048, 93, 24096, 78, 24096, 88, 24096, 91, 24144, 59, 24144, 74, 24144, 88, 24144, 91, 24192, 62, 24192, 69, 24240, 74, 24288, 78, 24288, 90, 24288, 93, 24336, 62, 24336, 74, 24336, 86, 24336, 90, 24384, 59, 24384, 71, 24432, 74, 24480, 78, 24480, 88, 24480, 91, 24528, 59, 24528, 74, 24528, 81, 24528, 86, 24576, 62, 24576, 69, 24624, 74, 24672, 78, 24720, 62, 24720, 74, 24768, 59, 24768, 71, 24816, 74, 24864, 78, 24912, 59, 24912, 74, 24960, 64, 24960, 71, 24960, 88, 25008, 76, 25056, 79, 25056, 90, 25104, 64, 25104, 76, 25104, 91, 25152, 64, 25152, 71, 25200, 66, 25200, 76, 25248, 67, 25248, 79, 25248, 88, 25296, 76, 25344, 57, 25344, 69, 25344, 85, 25392, 73, 25440, 79, 25440, 86, 25488, 57, 25488, 73, 25488, 88, 25536, 57, 25536, 69, 25584, 59, 25584, 73, 25584, 81, 25632, 61, 25632, 79, 25632, 86, 25680, 57, 25680, 73, 25680, 88, 25728, 58, 25728, 70, 25728, 89, 25776, 74, 25776, 88, 25824, 81, 25824, 86, 25872, 70, 25872, 77, 25872, 84, 25920, 81, 25968, 77, 26016, 70, 26016, 77, 26016, 81, 26016, 81, 26064, 57, 26064, 77, 26064, 79, 26064, 82, 26112, 65, 26112, 72, 26112, 77, 26112, 81, 26112, 84, 26160, 81, 26208, 72, 26208, 77, 26208, 84, 26208, 89, 26256, 65, 26304, 60, 26304, 72, 26304, 76, 26304, 84, 26304, 88, 26352, 79, 26352, 86, 26400, 72, 26400, 76, 26400, 82, 26400, 86, 26448, 60, 26448, 81, 26448, 84, 26496, 58, 26496, 70, 26496, 74, 26496, 82, 26496, 86, 26544, 81, 26544, 82, 26544, 84, 26592, 70, 26592, 74, 26592, 81, 26592, 84, 26640, 58, 26640, 76, 26688, 65, 26688, 72, 26688, 77, 26688, 81, 26688, 84, 26736, 81, 26784, 72, 26784, 77, 26784, 79, 26784, 81, 26832, 65, 26832, 77, 26832, 82, 26880, 65, 26880, 72, 26880, 77, 26880, 77, 26880, 84, 26928, 81, 26976, 72, 26976, 77, 26976, 81, 26976, 89, 27024, 65, 27072, 60, 27072, 72, 27072, 76, 27072, 82, 27072, 91, 27120, 79, 27120, 81, 27120, 89, 27168, 72, 27168, 76, 27168, 79, 27168, 88, 27216, 60, 27216, 77, 27216, 86, 27264, 58, 27264, 70, 27264, 74, 27264, 77, 27264, 86, 27312, 79, 27312, 82, 27312, 88, 27360, 70, 27360, 74, 27360, 81, 27360, 89, 27408, 58, 27408, 76, 27456, 65, 27456, 72, 27456, 77, 27456, 81, 27456, 89, 27504, 81, 27552, 65, 27552, 72, 27552, 77, 27552, 82, 27552, 91, 27600, 60, 27600, 84, 27600, 93, 27648, 58, 27648, 70, 27648, 74, 27648, 86, 27648, 94, 27696, 79, 27696, 86, 27696, 94, 27744, 58, 27744, 70, 27744, 74, 27744, 84, 27744, 93, 27792, 79, 27792, 91, 27840, 60, 27840, 72, 27840, 76, 27840, 84, 27840, 91, 27888, 79, 27936, 60, 27936, 72, 27936, 76, 27936, 81, 27936, 89, 27984, 79, 27984, 82, 27984, 91, 28032, 65, 28032, 72, 28032, 77, 28032, 84, 28032, 93, 28080, 81, 28080, 84, 28080, 93, 28128, 64, 28128, 72, 28128, 77, 28128, 82, 28128, 91, 28176, 81, 28176, 89, 28224, 62, 28224, 74, 28224, 77, 28224, 81, 28224, 89, 28272, 81, 28320, 60, 28320, 74, 28320, 77, 28320, 79, 28320, 86, 28368, 77, 28368, 81, 28368, 84, 28416, 58, 28416, 70, 28416, 74, 28416, 77, 28416, 86, 28464, 79, 28464, 79, 28464, 89, 28512, 65, 28512, 70, 28512, 74, 28512, 81, 28512, 89, 28560, 79, 28560, 79, 28560, 88, 28608, 57, 28608, 69, 28608, 73, 28656, 79, 28656, 79, 28656, 88, 28704, 64, 28704, 69, 28704, 73, 28704, 81, 28704, 90, 28752, 79, 28752, 81, 28752, 90, 28800, 62, 28800, 69, 28848, 74, 28896, 78, 28944, 62, 28944, 74, 28992, 59, 28992, 71, 29040, 74, 29088, 78, 29088, 93, 29136, 59, 29136, 74, 29136, 93, 29184, 62, 29184, 69, 29184, 95, 29232, 74, 29232, 93, 29280, 78, 29280, 90, 29328, 62, 29328, 74, 29328, 86, 29376, 59, 29376, 71, 29424, 74, 29424, 88, 29424, 91, 29472, 78, 29472, 90, 29472, 93, 29520, 59, 29520, 74, 29520, 90, 29520, 93, 29568, 62, 29568, 69, 29616, 74, 29664, 78, 29712, 62, 29712, 74, 29760, 59, 29760, 71, 29808, 74, 29808, 93, 29856, 78, 29856, 93, 29904, 59, 29904, 74, 29904, 93, 29952, 62, 29952, 69, 29952, 95, 30000, 74, 30000, 93, 30048, 78, 30048, 90, 30096, 62, 30096, 74, 30096, 86, 30144, 59, 30144, 71, 30192, 74, 30192, 88, 30192, 91, 30240, 78, 30240, 90, 30240, 93, 30288, 59, 30288, 74, 30288, 90, 30288, 93, 30336, 62, 30336, 69, 30384, 74, 30432, 78, 30480, 62, 30480, 74, 30528, 59, 30528, 71, 30576, 74, 30576, 93, 30624, 78, 30624, 93, 30672, 59, 30672, 74, 30672, 93, 30720, 62, 30720, 69, 30720, 95, 30768, 74, 30768, 93, 30816, 78, 30816, 90, 30864, 62, 30864, 74, 30864, 86, 30912, 59, 30912, 71, 30960, 74, 30960, 88, 30960, 91, 31008, 78, 31008, 90, 31008, 93, 31056, 59, 31056, 74, 31056, 90, 31056, 93, 31104, 62, 31104, 69, 31152, 74, 31200, 78, 31248, 62, 31248, 74, 31296, 59, 31296, 71, 31344, 74, 31392, 78, 31392, 93, 31440, 59, 31440, 74, 31440, 93, 31488, 62, 31488, 69, 31488, 95, 31536, 74, 31536, 93, 31584, 78, 31584, 90, 31632, 62, 31632, 74, 31632, 86, 31680, 59, 31680, 71, 31728, 74, 31728, 88, 31728, 91, 31776, 78, 31776, 90, 31776, 93, 31824, 59, 31824, 74, 31824, 90, 31824, 93, 31872, 62, 31872, 69, 31920, 74, 31968, 78, 32016, 62, 32016, 74, 32064, 59, 32064, 71, 32112, 74, 32112, 93, 32160, 78, 32160, 93, 32208, 59, 32208, 74, 32208, 93, 32256, 62, 32256, 69, 32256, 95, 32304, 74, 32304, 93, 32352, 78, 32352, 90, 32400, 62, 32400, 74, 32400, 86, 32448, 59, 32448, 71, 32496, 74, 32496, 88, 32496, 91, 32544, 78, 32544, 90, 32544, 93, 32592, 59, 32592, 74, 32592, 90, 32592, 93, 32640, 62, 32640, 69, 32688, 74, 32736, 78, 32784, 62, 32784, 74, 32832, 59, 32832, 71, 32880, 74, 32880, 91, 32928, 78, 32928, 93, 32976, 59, 32976, 74, 32976, 93, 33024, 62, 33024, 69, 33072, 74, 33120, 78, 33168, 62, 33168, 74, 33216, 71, 33216, 71, 33264, 74, 33264, 91, 33312, 71, 33312, 78, 33312, 90, 33360, 69, 33360, 74, 33360, 90, 33791, 0 // 176 seconds * 48 * 4 - 1 };

    synth.asm

    .cdecls C, LIST, "msp430fr5739.h" .text .def set_tick .def get_tick .def synth_init .def set_note .ref wave .bss tick, 2 .bss pwm_out, 2 .bss phase_inc, 6 * 8 ; Level ; Phase increment LSW/MSW (from note table) .bss phase_acc, 4 * 8 ; Phase accumulator LSW/MSW .def phase_inc set_tick: mov R12, &tick reta get_tick: mov &tick, R12 reta synth_init: mov #0x0210, &TA0CTL ; Timer A config: SMCLK, count up mov #749, &TA0CCR0 ; Setup Timer A period for 32000 sps mov #375, &TA0CCR1 ; Setup Timer A compare mov #0x00E0, &TA0CCTL1 ; Setup Timer A reset/set output mode ; mov #phase_inc, R12 ; Clear all phase inc and accum mov #5 * 16, R14 ; Word count clr 0(R12) ; Clear word incd R12 ; Next word dec R14 ; Dec word count jne $ - 8 ; Loop until all words done... ; eint ; Enable interupts bis #0x0010, &TA0CCTL0 ; Enable PWM interupt ; reta ; ; synth_isr: ; mov &pwm_out, &TA0CCR1 ; Output sample ; push R4 ; Wavetable pointer push R5 ; Phase increment / level pointer push R6 ; Phase accumulator pointer push R8 ; Wave sample pointer / next sample push R9 ; Wave sample push R10 ; Voice mix accumulator MSW push R11 ; Voice mix accumulator LSW ; mov #wave, R4 ; Setup wavetable pointer mov #phase_inc, R5 ; Setup phase increment and level pointer mov #phase_acc, R6 ; Setup phase accumulator pointer clr R10 ; Clear voice mix clr R11 ; voice_loop: ; .loop 8 mov @R6+, &MPYS32L ; Get phase acc LSW (fraction) to multiplier mov @R6+, R8 ; Get phase acc MSW (wave table index) ; bit #0xFF00, R8 ; Test phase acc MSB mov.b R8, R8 ; Clear MSB ;jeq no_decay ; jeq $ + 22 mov @R5, &MPY ; Get level mov #0xFF00, &OP2 ; Decay factor mov R8, -2(R6) ; Update phase acc mov &RES1, 0(R5) ; Update level ;no_decay: clr &MPYS32H ; add R8, R8 ; Make word index add R4, R8 ; Add wavetable pointer mov @R8+, R9 ; Get wave sample mov @R8, R8 ; Get next wave sample sub R9, R8 ; Calc delta mov R8, &OP2L ; Multiply by delta bit #0x8000, R8 ; Sign extend delta subc R8, R8 ; inv R8 ; mov R8, &OP2H ; add &RES1, R9 ; Add interpolation to sample mov R9, &MPYS ; Multiply by voice level mov @R5+, &OP2 ; add @R5+, -4(R6) ; Update phase acc addc @R5+, -2(R6) ; add &RES0, R11 ; Update mix addc &RES1, R10 ; ; .endloop ; swpb R10 ; Use MSB of R10 mov.b R10, R10 ; sxt R10 ; Sign extend add R10, R10 ; * 2 add #375, R10 ; Bias to center of PWM range mov R10, &pwm_out ; ; dec &tick ; jc $ + 6 ; clr &tick ; ; pop R11 ; pop R10 ; pop R9 ; pop R8 ; pop R6 ; pop R5 ; pop R4 ; reti ; ; set_note: ; mov R12, R15 ; Voice * 6 add R15, R12 ; (+1 = *2) add R15, R12 ; (+1 = *3) rla R12 ; (*2 = *6) add #phase_inc, R12 ; Add phase inc pointer mov R14, 0(R12) ; Set level cmp #128, R13 ; Out of range note values are note off jhs note_off ; clr R14 ; Clear octave count tst_note: ; cmp #116, R13 ; Within note table? jge get_pi ; Yes... inc R14 ; Inc octave count add #12, R13 ; Add octave to note jmp tst_note ; Check again... get_pi: ; Get phase increment sub #116, R13 ; Adjust for first note in table rla R13 ; MIDI note * 4 rla R13 ; add #notes, R13 ; Add note table pointer mov @R13+, R15 ; Get LSW mov @R13, R13 ; Get MSW tst R14 ; Shifting required? jeq set_phase ; No... shift_phase: ; rra R13 ; Shift phase inc rrc R15 ; dec R14 ; Dec octave count jne shift_phase ; Repeat until zero... set_phase: ; mov R15, 2(R12) ; Set phase inc mov R13, 4(R12) ; reta ; Return ; note_off: ; incd SP ; Discard level clr 0(R12) ; Clear phase inc clr 2(R12) ; .if 0 ; Note: Abrupt return to zero causes poping clr 4(R12) ; Clear level add #phase_acc - phase_inc, R12 ; Phase accum pointer clr 0(R12) ; Clear phase accum clr 2(R12) ; .endif ; reta ; Return ; ; notes ; MIDI Note Frequency .long 3483828 ; 116 G#8 6644.87457275391 .long 3690988 ; 117 A8 7040.00091552734 .long 3910465 ; 118 A#8 7458.62007141113 .long 4142993 ; 119 B8 7902.13203430176 .long 4389349 ; 120 C9 8372.01881408691 .long 4650353 ; 121 C#9 8869.84443664551 .long 4926877 ; 122 D9 9397.27210998535 .long 5219845 ; 123 D#9 9956.06422424316 .long 5530233 ; 124 E9 10548.0823516846 .long 5859077 ; 125 F9 11175.3025054932 .long 6207476 ; 126 F#9 11839.8208618164 .long 6576592 ; 127 G9 12543.8537597656 ; Interrupt Vectors .sect ".int53" ; TA0CCR0 CCIFG0 .short synth_isr ; ; .end ;
  8. Like
    tripwire reacted to oPossum in music with assembly language   
    A variation of the RTTL player that adds a simple envelope to each note.
     

     
     
     
    Some in assembly & C:
     
    MIDI driven:
     

     
    http://forum.43oh.com/topic/810-fraunchpad-poly-synth/
     
    This has a bug that causes only half of the sine wave to be used. Look carefully at the 'scope and you will see it.
     
     
    Table driven:
     
    This has a bug that causes the frequency to be a bit off. Don't remember if I fixed the posted code.
     

     

     
    http://forum.43oh.com/topic/1729-fraunchpad-synth-still-alive/
  9. Like
    tripwire reacted to greeeg in Custom EzFet Lite   
    @@zeke I've added this to the silk on one of my new boards, Guess I'll see how it turns out.

     
    Feels like there is too much free space in the clock.
  10. Like
    tripwire reacted to sq7bti in Educational BoosterPack 8 bit FFT Spectrum Analyzer Attempt   
    Hi,
     
    Having a nice matrix led display laying around with no use of I assembled a test circuit with launchpad and modified the code of @simpleavr to run on it.

    The display is driven by four MAX7219 chips chained on SPI bus. I noticed that the only floating point operation that your code was using is a square root operation in line 257. Once I added a fixed-point square root routine, linking with math lib is not necessary anymore - spared a lot of flash space. The fixed-point routine is also 3 times faster than mathlib floating point one: 50us vs 150us
    #ifdef FLOATING_POINT // sqrt: 150us #include <math.h> #else // FLOATING_POINT // 50us unsigned char sqrt16(unsigned short a) { unsigned short rem = 0, root = 0; int i; for(i = 0; i < 8; ++i) { root <<= 1; rem = ((rem << 2) + (a >> 14)); a <<= 2; ++root; if(root <= rem) { rem -= root; ++root; } else { --root; } } return (unsigned char)(root >> 1); } #endif // FLOATING_POINT Further I've added Hamm windowing to minimize spectral leakage:
    // scilab 255 * window('kr',64,6) //const unsigned short hamming[32] = { 4, 6, 9, 13, 17, 23, 29, 35, 43, 51, 60, 70, 80, 91, 102, 114, 126, 138, 151, 163, 175, 187, 198, 208, 218, 227, 234, 241, 247, 251, 253, 255 }; // scilab 255 * window('kr',64,4) const unsigned short hamming[32] = { 23, 29, 35, 42, 50, 58, 66, 75, 84, 94, 104, 113, 124, 134, 144, 154, 164, 174, 183, 192, 201, 210, 217, 224, 231, 237, 242, 246, 250, 252, 254, 255 }; // scilab 255 * window('kr',64,2) //const unsigned short hamming[32] = { 112, 119, 126, 133, 140, 147, 154, 161, 167, 174, 180, 186, 192, 198, 204, 209, 214, 219, 224, 228, 232, 236, 239, 242, 245, 247, 250, 251, 253, 254, 255, 255 }; Applying windowing on 32 samples uses fixed point math:
    for (i=0;i<Nx;i++) { int hamm = hamming[i<(FFT_SIZE-1)?i:(Nx-1)-i] * data[i]; data[i] = (hamm >> 8); } Finally the display buffer is filled in with output of FFT function:
            unsigned long mask = 1UL;         for (i=0; i<32; ++i, mask <<= 1) {             for(j=0;j<8;++j) {                 if(j<plot[i])                     dbuff.ulongs[j] |= mask;                 else                     dbuff.ulongs[j] &= ~(mask);             }         } where dbuff is display buffer organized as:
    typedef union { unsigned long longs; unsigned int ints[2]; unsigned char chars[4]; } longbytes; union { unsigned char bytes[8*4]; longbytes lbytes[8]; unsigned long ulongs[8]; } dbuff; which make it easy to manipulate:
    unsigned char spibuff[8]; void SPI_Write(unsigned char* array) { P2OUT &= ~LED_CS; __delay_cycles(50); unsigned int h = 8; while(h) { UCB0TXBUF = *array; while (UCB0STAT & UCBUSY); ++array; --h; } P2OUT |= LED_CS; } void update_display() { unsigned char i; for(i = 0; i < 8; ++i) { spibuff[0] = spibuff[2] = spibuff[4] = spibuff[6] = i+1; spibuff[1] = dbuff.lbytes[i].chars[3]; spibuff[3] = dbuff.lbytes[i].chars[2]; spibuff[5] = dbuff.lbytes[i].chars[1]; spibuff[7] = dbuff.lbytes[i].chars[0]; SPI_Write(spibuff); } } BTW I got a second 8x32 led matrix displays from the same ebay offer, and it turned out to be mirrored - LED matrix is turned around 180deg, so the update_display() routine for the other one have to push bytes in order 0 through 3, and bit-shift operations ( << and >> ) yield opposite display reaction (left vs right scroll).
     
    https://youtu.be/Nen6yd5kvZs
     
    s.
     
    Edit: correct photo attachement and source code snippets
    led_fft.tar.bz2
  11. Like
    tripwire reacted to chicken in CAL.430FR: MSP430 Wrist Watch   
    @@bluehash I don't know him. I found the blog via my Github stats as he links to my Energia library for the display.
  12. Like
    tripwire reacted to greeeg in ledClock - dual colour led matrix   
    Hey Guys,
     
    Exam times again, so I feel like I have a tonne of time for my projects.
    This is a project I started in February 2014. I found a very nice 8x8 dual colour LED display. I designed a PCB for them when I ordered them, instead of when I actually had them.

    I had built a PCB up with a G2542 8kb / 512b (Mem/RAM) but didn't manage to get it working.
     
    Over the last few weeks I got back into this project, and low and behold it did actually work!!

     
    I built up a new PCB because it was designed as a common cathode driver, but the displays were common anode.... (on the first board, I had bridged the common mosfets.)

    of course using 0402 parts. (this display need 64 of these O_O)

    back of PCB contains clock, half a DCDC stepup and a BMA222 accelerometer.

     
    Front & back


     
    Now I needed a case, this is my first project I decided to actually make use of a cheap chinesse laser cutter I now own.

     
    The piece with all the slits in it create a "living hinge" which creates a cool organic looking case. as opposed to a rectangle.

     
    I'm still working on improving code. Basic clock functionality is in.
     
    lastly I'll leave you with my dud designs. which while not very practical. are actually 100% useful. A failed design can teach you alot!

     
    I will be making this open source, I would like to make more in the future, which may involve buying more displays from china (if there is interest maybe even a group buy?? )
     
  13. Like
    tripwire reacted to p2baron in [SOLVED] Is this code blocking suspend()/lpm4?   
    I think I've found the culprit with the help of this article: http://www.elevendroids.com/2013/06/code-recipe-reading-msp430-power-supply-voltage-level/
     
    If I add "ADC10CTL0 &= ~ENC;" to wiring_analog.c the problem is solved.
     
    i.e. 
    #if defined(__MSP430_HAS_ADC10__) ADC10CTL0 &= ~ADC10ENC; // disable ADC ADC10CTL1 = ADC10SSEL_0 | ADC10DIV_4; // ADC10OSC as ADC10CLK (~5MHz) / 5 ADC10CTL0 = analog_reference | // set analog reference ADC10ON | ADC10SHT_3 | ADC10IE; // turn ADC ON; sample + hold @ 64
  14. Like
    tripwire reacted to chicken in CAL.430FR: MSP430 Wrist Watch   
    Just came across this very well documented project (not mine):
    http://blog.kemushicomputer.com/search/label/MSP430 ( translate)
    https://github.com/kentN/CAL430FR
     
    It's a wrist watch featuring Energia (incl. custom pin map), MSP430FR5949, Sharp Memory LCD and an accelerometer.

     
    KentN, if you're reading this: great job!
     
     


  15. Like
    tripwire reacted to roadrunner84 in Interfacing a LCD (4-bit mode) to the MSP430g2553 in assembly   
    Why would you want to do it in assembly? You could of course just compile the C code and see what assembly code rolls out.
  16. Like
    tripwire reacted to greeeg in Ambiq: game changer in Ultra Low Power?   
    Looking at the specs though the hardware is lacking compared to most other MCUs on the market. a small assortment of Serial IO/s an ADC, and some timers. No DMA which means you actually need to wake up the processor to do stuff.
    Also for these tests they have disabled half their flash and 7/8's of the RAM is powered down.
     
    It does have impressive specs. But I would argue that in a final product. the average consumption would be more typical. Still very interesting
  17. Like
    tripwire reacted to StefanoDS in Ambiq: game changer in Ultra Low Power?   
    These scores suggest a real >2x performance breakthrough in low power consumption from Ambiq Micro's Apollo device:
     
    http://www.eembc.org/ulpbench/index.php
     
    I wonder if this technology is really ready for prime time and how the current industry leaders (TI, STM etc...) will respond/react... What do you think?
  18. Like
    tripwire got a reaction from KatiePier in Timer works only with CCS debugger   
    It looks like the sparkfun crystal is slightly bigger than the stock launchpad one. It's also a through-hole part rather than SMT. I think it would be possible to push the leads through the plated through-holes on either side of the pads used by the stock SMT crystal. Then you could solder the two wires from the back of the board, which might be easier than surface mounting.
     
    The body connection can probably be made with the sparkfun crystal even though it doesn't have a flat underside. Having said that, the body connection is not essential. It grounds the case, which helps to shield against any interference. It should still work just fine without it, and it's better to leave it unconnected than to overheat the crystal if you're finding it awkward to solder.
  19. Like
    tripwire reacted to bluehash in TI's new CapTIvate MSP430 controllers   
    TI announced their new CapTIvate MSP430 controllers today. TI has been implementing capacitive touch via their CapTouch software library. having moved cap touch to hardware will definitely help touch performance and battery life.
     
    To evaluate CapTIvate, TI is selling a MCU Development Kit for $99.00. It consists of the MSP430FR2633 microcontroller board, a programmer/debugger board with EnergyTrace
  20. Like
    tripwire reacted to roadrunner84 in Flash memory can be damaged by writes? (and related things)   
    If you're in need of big memory, then yes. But in most cases you'd need to log only a dozen or so entries, then using on-chip memory is much more interesting.
    Also, note it's 512 kilobits, so that's 64 kilobytes. Still quite a bit of space. If you really need a LOT of memory, you could also consider using an SD card instead. SD cards are essentially just serial flash, not so different from EEPROMs. If you ditch the FAT filesystem, you don't need that much code to use them at all!
  21. Like
    tripwire got a reaction from JohnDough in Timer works only with CCS debugger   
    It looks like the sparkfun crystal is slightly bigger than the stock launchpad one. It's also a through-hole part rather than SMT. I think it would be possible to push the leads through the plated through-holes on either side of the pads used by the stock SMT crystal. Then you could solder the two wires from the back of the board, which might be easier than surface mounting.
     
    The body connection can probably be made with the sparkfun crystal even though it doesn't have a flat underside. Having said that, the body connection is not essential. It grounds the case, which helps to shield against any interference. It should still work just fine without it, and it's better to leave it unconnected than to overheat the crystal if you're finding it awkward to solder.
  22. Like
    tripwire reacted to Rickta59 in USCI patch for parity   
    I was trying to port a sketch that used the Serial port with non standard UART parity and character length to Energia.  I noticed that the UART port isn't setup to handle anything except 8-N-1.  While the code below can't do all the combinations that are available to the atmega, it can do 7/8 bit, even/odd parity and 1/2 stop bits.  I created a patch that will at least fix it for the chip I am using (msp430g2553).  It will need some work for other chips. Apply the attached patch to the source of the latest Energia source tree. (as of 11/11/2015)
     
    -rick
     
    (See new optional second parameter https://www.arduino.cc/en/Serial/Begin )
    parity.patch
  23. Like
    tripwire reacted to roadrunner84 in Flash memory can be damaged by writes? (and related things)   
    Most flash memory can only be written to 0 values in their bits, the erase cycle will set all bits to 1 again. So writing a byte, say 10101010 and then writing 01010101 will result in a byte read as 00000000. To avoid such behaviour, you should always erase between write cycles. Alternatively, always write 11111111 to any byte you do not want to touch.
    Also, as suggested before, try not to keep bookkeeping data in flash (like the end-of-array-pointer). Instead, make sure the default value after erasing is not a valid statement, as a result, you can determine the end of your array by iterating over it to check for this end value.
     
    @@hmjswt You could do that... but why? There is flash and EEPROM-emulating-flash in these chips. Replacing the microcontroller is probably cheaper these days than adding more components in case the EEPROM dies. As suggested before, using an FRAM part would be nice too, since there is no real difference between RAM and flash on those, it's non-volatile RAM.
  24. Like
    tripwire reacted to terjeio in Timer works only with CCS debugger   
    @@JohnDough What is your ACLK source and the delayCycles value? Is the LED partly lit?
  25. Like
    tripwire reacted to JohnDough in Timer works only with CCS debugger   
    @@terjeio
     
    Your question "What is your ACLK source" led me to do a small research -
    I added this line:
     
    BCSCTL3 |= LFXT1S_2;
     
    and problem solved.
     
    Oddly, it was missing from the example I used which was specific to timers.
     
    Thanks for your help !
×
×
  • Create New...