Jump to content
43oh

SirZusa

Members
  • Content Count

    105
  • Joined

  • Last visited

Reputation Activity

  1. Like
    SirZusa reacted to bluehash in Get your Booster Packs Sponsored - $10   
    Hello guys..This has been at the back of my head for a long time. So lets start at Booster Packs.

    43oh will be glad to sponsor your initial Booster Pack[bP] development. $10 will be awarded to you to make initial PCBs or purchase parts. It's not much, but it is an incentive. A max of two BPs will be sponsored/month.

    Your selection depends on the following factors:
    [1] Be a member on this forum for at least 4 weeks and have a minimum of 20 posts.
    [2] A thread in the Booster Pack sub-forum.
    [3] Create initial schematics and layouts in the thread, including selection of parts.
    [4] BP usable by a large number of people.
    [5] Open source your schematic and PCB Files. Git it if you have to, but keep a copy on the Forum.
    [6] Some amount of test code if the success of your Booster Pack depends on it.
    [7] A voting system for the community to decide if the BP needs to be sponsored. I'm not sure how many votes make a good BP. If there are enough "Yes" votes(more than 50%) than "No"... your sponsored.

    I can't think of anything else.I'd also like to put a donate button for members to donate towards the pool. Would there be any interest in this? Donations will be made public to ensure transparency. I would appreciate the communities response to the idea. This will also help increase the number of sponsorships/month.

    There is no liability once you are sponsored(since the schematics/PCB files have been shared). It's a matter of mutual understanding that you will not run away with the boards. Maybe give them away with the interested party paying for shipping.

    One thing to keep in mind is to keep this KISS - Keep It Simple, Stupid.
    Also, no arguing, but intelligent debate when voting. This is NOT a competition.
  2. Like
    SirZusa got a reaction from nuetron in Did I fry my LP in some strange way?   
    hmmm ... shortcut them on emulator-side ... connect with terminal to your comport - 9600 N 1 - and send something - then it should return the same data - i often have problems when using RX/TX with the emulator and flashing my
  3. Like
    SirZusa got a reaction from gwdeveloper in Faster division of a float?   
    x / y
     
    multiply x by 10000 and truncate it - so you get an integer out of the float with 4 decimals, then do a normal integer - integer - division ... and in the last step divide it by 10000 to get the result - i dont know if it is faster - but you can give it a try
     
    something like this (untested)

    float x = 1.234567; int y = 7; int z = x * 10000; float result = z / (y * 10000);
  4. Like
    SirZusa reacted to oPossum in CNC-milling: create 3 different frequencies with MSP430G2553   
    Here is some code that uses NCOs to generate three frequencies with 100 uHz (0.0001 Hz) resolution for a specified duration.
     
    There will be some jitter when 100000 / Frequency is not an integer. This may or may not be a problem. There are ways to reduce the jitter, but more hardware is required.
     
    Be very careful with the ISR code - it must be able to run in under 120 cycles.
     

    #include "msp430g2553.h" static long int timer = 0; // Duration of motion static long int pix = 0; // Phase increment static long int piy = 0; static long int piz = 0; static long int px = 0; // Position static long int py = 0; static long int pz = 0; static long int dx = 1; // Direction static long int dy = 1; static long int dz = 1; // Sample rate * (1 / resolution in Hz) static const long int pl = 1000000000; void set_fx(long int f) { pix = f - pl; } void set_fy(long int f) { piy = f - pl; } void set_fz(long int f) { piz = f - pl; } void main(void) { WDTCTL = WDTPW | WDTHOLD; // Disable watchdog DCOCTL = 0; BCSCTL1 = CALBC1_16MHZ; // Set DCO to 16 MHz DCOCTL = CALDCO_16MHZ; // P1DIR = 0x13; // I/O assignment P1REN = 0x00; // P1OUT = 0x02; // P1SEL = 0x10; // Enable SMCLK output P2DIR = 0x07; // P2REN = 0x00; // P2OUT = 0x00; // P2SEL = 0xC0; // TA0CTL = TASSEL_2 | MC_1; // Timer A config: SMCLK, count up TA0CCR0 = 160 - 1; // Setup Timer A CCR0 period for 100,000 Hz TA0CCTL0 |= CCIE; // Enable PWM interrupt _EINT(); // Enable interrupts set_fx(10000000); // 1000.0000 Hz set_fy(20000000); // 2000.0000 Hz set_fz(25000000); // 2500.0000 Hz timer = -1; // Run for a long time for(;; } #pragma vector = TIMER0_A0_VECTOR __interrupt void timer_a_isr(void) { static long int pax = 0; // Phase accumulator static long int pay = 0; static long int paz = 0; if(timer) { --timer; pax += pix; if(pax < 0) pax += pl; else { P2OUT |= 1; px += dx; P2OUT &= ~1; } pay += piy; if(pay < 0) pay += pl; else { P2OUT |= 2; py += dy; P2OUT &= ~2; } paz += piz; if(paz < 0) paz += pl; else { P2OUT |= 4; pz += dz; P2OUT &= ~4; } } }
  5. Like
    SirZusa got a reaction from GeekDoc in Content driven AmbientLight /// LightPack-Clone   
    Hey, i once again made some changes to the pcb.
     
    - thicker power-traces
    - less traces between pads
    - less vias
    - more spacing where possible
     
    i attached the brd-file so you can have a look on it, change it and do whatever you want - except commercial usage
     
    hmmm... i did not think about a name till now. i dont want to use AmbiLight because of the name (philips) :crazy:
     
    @bluehash - i did not send it to fabrication for now because i want a second layout on it for another project so i can save some

    LightPackClone v1.brd
  6. Like
    SirZusa got a reaction from bluehash in Run placement fails   
    this is not possible - if it needs to be modifiable / variable - you need to store it in RAM - and if you are out of RAM you will need a bigger MCU
     
    seems like the F5529 is already the biggest of this series with 8192 Bytes of RAM?
    What do you store in there? Maybe you can change the type of the vars? (eg. Byte instead of integer for unsigned values ranging 0 - 255) or optimize your code - reduce the global vars
     
    without knowing your program it is hard to say where to begin
     
    edit: in IAR the last debug-lines:
  7. Like
    SirZusa reacted to RobG in 4ch Volt Meter using Nokia 5110   
    This is just to show what can be done with 5110.
    FYI, inputs are floating, top bar is P1.3, which is pulled-up by default, values are raw, not calibrated.




    #include "msp430g2553.h" #include "PCD8544.h" #define LCD5110_SCLK_PIN BIT5 #define LCD5110_DN_PIN BIT7 #define LCD5110_SCE_PIN BIT4 #define LCD5110_DC_PIN BIT6 #define LCD5110_SELECT P1OUT &= ~LCD5110_SCE_PIN #define LCD5110_DESELECT P1OUT |= LCD5110_SCE_PIN #define LCD5110_SET_COMMAND P1OUT &= ~LCD5110_DC_PIN #define LCD5110_SET_DATA P1OUT |= LCD5110_DC_PIN #define LCD5110_COMMAND 0 #define LCD5110_DATA 1 void writeStringToLCD(const char *string); void writeCharToLCD(char c); void writeToLCD(unsigned char dataCommand, unsigned char data); void clearLCD(); void setAddr(unsigned char xAddr, unsigned char yAddr); void initLCD(); void binaryToUnpackedBCD(unsigned int n, unsigned char * digits); unsigned char bcd[4] = {0,0,0,0}; int adc[4] = {0,0,0,0}; unsigned char last[4] = {0,0,0,0}; static const char tick[64] = { 0x07, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x07, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x07, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x07, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x07, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x07, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x06, 0x04, 0x07, 0x04, 0x06, 0x04 }; void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_1MHZ; // 1MHz clock DCOCTL = CALDCO_1MHZ; P1OUT |= LCD5110_SCE_PIN + LCD5110_DC_PIN; P1DIR |= LCD5110_SCE_PIN + LCD5110_DC_PIN; // setup USIB P1SEL |= LCD5110_SCLK_PIN + LCD5110_DN_PIN; P1SEL2 |= LCD5110_SCLK_PIN + LCD5110_DN_PIN; UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // 1:1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // clear SW ADC10CTL1 = INCH_3 + CONSEQ_1; ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; ADC10DTC1 = 0x04; ADC10AE0 |= 0x0F; _delay_cycles(500000); initLCD(); clearLCD(); // LCD test writeStringToLCD("4ch Volt Meter"); setAddr(0,5); writeStringToLCD("by RobG @ 43oh"); char c = 0; // setup tickmarks char d = 0; while(d < 4) { d++; c = 0; setAddr(0,d); while(c < 64) { writeToLCD(LCD5110_DATA, tick[c]); c++; } } _bis_SR_register(GIE); while(1) { ADC10SA = (unsigned int)&adc[0]; ADC10CTL0 |= ENC + ADC10SC; _delay_cycles(100000); } } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { ADC10CTL0 &= ~ENC; char c = 0; while(c < 4) { unsigned char curr = adc[c] >> 4; unsigned char prev = last[c]; unsigned char b = 0; unsigned char t = 0; binaryToUnpackedBCD(curr, bcd); if(curr < prev) { setAddr(curr, c + 1); b = prev - curr + 1; t = curr; while(b > 0) { writeToLCD(LCD5110_DATA, tick[t++]); b--; } } else if(curr > prev) { setAddr(prev, c + 1); b = curr - prev; t = prev; while(b > 0) { writeToLCD(LCD5110_DATA, 0x70 | tick[t++]); b--; } } setAddr(70 ,c + 1); writeCharToLCD(bcd[2] + 0x30); writeToLCD(LCD5110_DATA, 0x40); writeToLCD(LCD5110_DATA, 0x0); writeCharToLCD(bcd[3] + 0x30); last[c] = curr; c++; } } void writeStringToLCD(const char *string) { while(*string) { writeCharToLCD(*string++); } } void writeCharToLCD(char c) { unsigned char i; for(i = 0; i < 5; i++) { writeToLCD(LCD5110_DATA, font[c - 0x20][i]); } writeToLCD(LCD5110_DATA, 0); } void writeToLCD(unsigned char dataCommand, unsigned char data) { LCD5110_SELECT; if(dataCommand) { LCD5110_SET_DATA; } else { LCD5110_SET_COMMAND; } UCB0TXBUF = data; while(!(IFG2 & UCB0TXIFG)) ; LCD5110_DESELECT; } void clearLCD() { setAddr(0, 0); int c = 0; while(c < PCD8544_MAXBYTES) { writeToLCD(LCD5110_DATA, 0); c++; } setAddr(0, 0); } void setAddr(unsigned char xAddr, unsigned char yAddr) { writeToLCD(LCD5110_COMMAND, PCD8544_SETXADDR | xAddr); writeToLCD(LCD5110_COMMAND, PCD8544_SETYADDR | yAddr); } void initLCD() { writeToLCD(LCD5110_COMMAND, PCD8544_FUNCTIONSET | PCD8544_EXTENDEDINSTRUCTION); writeToLCD(LCD5110_COMMAND, PCD8544_SETVOP | 0x3F); writeToLCD(LCD5110_COMMAND, PCD8544_SETTEMP | 0x02); writeToLCD(LCD5110_COMMAND, PCD8544_SETBIAS | 0x03); writeToLCD(LCD5110_COMMAND, PCD8544_FUNCTIONSET); writeToLCD(LCD5110_COMMAND, PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL); } void binaryToUnpackedBCD(unsigned int n, unsigned char * digits) { __asm(" clr R14"); __asm(" rla R12"); __asm(" rla R12"); __asm(" rla R12"); __asm(" rla R12"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" rla R12"); __asm(" dadd R14, R14"); __asm(" mov.b R14, 3(R13)"); __asm(" swpb R14"); __asm(" mov.b R14, 1(R13)"); __asm(" rra R14"); __asm(" rra R14"); __asm(" rra R14"); __asm(" rra R14"); __asm(" mov.b R14, 0(R13)"); __asm(" swpb R14"); __asm(" mov.b R14, 2(R13)"); __asm(" and #0x0F0F, 0(R13)"); __asm(" and #0x0F0F, 2(R13)"); return; }
    #ifndef PCD8544_H_#define PCD8544_H_#define PCD8544_POWERDOWN 0x04#define PCD8544_ENTRYMODE 0x02#define PCD8544_EXTENDEDINSTRUCTION 0x01#define PCD8544_DISPLAYBLANK 0x0#define PCD8544_DISPLAYNORMAL 0x4#define PCD8544_DISPLAYALLON 0x1#define PCD8544_DISPLAYINVERTED 0x5// H = 0#define PCD8544_FUNCTIONSET 0x20#define PCD8544_DISPLAYCONTROL 0x08#define PCD8544_SETYADDR 0x40#define PCD8544_SETXADDR 0x80#define PCD8544_HPIXELS 84#define PCD8544_VBANKS 6#define PCD8544_MAXBYTES 504 // PCD8544_HPIXELS * PCD8544_VBANKS// H = 1#define PCD8544_SETTEMP 0x04#define PCD8544_SETBIAS 0x10#define PCD8544_SETVOP 0x80//transform#define NONE 0x00#define FLIP_H 0x01#define FLIP_V 0x02#define ROTATE 0x04 // 90 deg CW#define ROTATE_90_CW ROTATE#define ROTATE_90_CCW (FLIP_H | FLIP_V | ROTATE)#define ROTATE_180 (FLIP_H | FLIP_V)static const char font[][5] = { // basic font{0x00, 0x00, 0x00, 0x00, 0x00} // 20,{0x00, 0x00, 0x5f, 0x00, 0x00} // 21 !,{0x00, 0x07, 0x00, 0x07, 0x00} // 22 ",{0x14, 0x7f, 0x14, 0x7f, 0x14} // 23 #,{0x24, 0x2a, 0x7f, 0x2a, 0x12} // 24 $,{0x23, 0x13, 0x08, 0x64, 0x62} // 25 %,{0x36, 0x49, 0x55, 0x22, 0x50} // 26 &,{0x00, 0x05, 0x03, 0x00, 0x00} // 27 ',{0x00, 0x1c, 0x22, 0x41, 0x00} // 28 (,{0x00, 0x41, 0x22, 0x1c, 0x00} // 29 ),{0x14, 0x08, 0x3e, 0x08, 0x14} // 2a *,{0x08, 0x08, 0x3e, 0x08, 0x08} // 2b +,{0x00, 0x50, 0x30, 0x00, 0x00} // 2c ,,{0x08, 0x08, 0x08, 0x08, 0x08} // 2d -,{0x00, 0x60, 0x60, 0x00, 0x00} // 2e .,{0x20, 0x10, 0x08, 0x04, 0x02} // 2f /,{0x3e, 0x51, 0x49, 0x45, 0x3e} // 30 0,{0x00, 0x42, 0x7f, 0x40, 0x00} // 31 1,{0x42, 0x61, 0x51, 0x49, 0x46} // 32 2,{0x21, 0x41, 0x45, 0x4b, 0x31} // 33 3,{0x18, 0x14, 0x12, 0x7f, 0x10} // 34 4,{0x27, 0x45, 0x45, 0x45, 0x39} // 35 5,{0x3c, 0x4a, 0x49, 0x49, 0x30} // 36 6,{0x01, 0x71, 0x09, 0x05, 0x03} // 37 7,{0x36, 0x49, 0x49, 0x49, 0x36} // 38 8,{0x06, 0x49, 0x49, 0x29, 0x1e} // 39 9,{0x00, 0x36, 0x36, 0x00, 0x00} // 3a :,{0x00, 0x56, 0x36, 0x00, 0x00} // 3b ;,{0x08, 0x14, 0x22, 0x41, 0x00} // 3c <,{0x14, 0x14, 0x14, 0x14, 0x14} // 3d =,{0x00, 0x41, 0x22, 0x14, 0x08} // 3e >,{0x02, 0x01, 0x51, 0x09, 0x06} // 3f ?,{0x32, 0x49, 0x79, 0x41, 0x3e} // 40 @,{0x7e, 0x11, 0x11, 0x11, 0x7e} // 41 A,{0x7f, 0x49, 0x49, 0x49, 0x36} // 42 B,{0x3e, 0x41, 0x41, 0x41, 0x22} // 43 C,{0x7f, 0x41, 0x41, 0x22, 0x1c} // 44 D,{0x7f, 0x49, 0x49, 0x49, 0x41} // 45 E,{0x7f, 0x09, 0x09, 0x09, 0x01} // 46 F,{0x3e, 0x41, 0x49, 0x49, 0x7a} // 47 G,{0x7f, 0x08, 0x08, 0x08, 0x7f} // 48 H,{0x00, 0x41, 0x7f, 0x41, 0x00} // 49 I,{0x20, 0x40, 0x41, 0x3f, 0x01} // 4a J,{0x7f, 0x08, 0x14, 0x22, 0x41} // 4b K,{0x7f, 0x40, 0x40, 0x40, 0x40} // 4c L,{0x7f, 0x02, 0x0c, 0x02, 0x7f} // 4d M,{0x7f, 0x04, 0x08, 0x10, 0x7f} // 4e N,{0x3e, 0x41, 0x41, 0x41, 0x3e} // 4f O,{0x7f, 0x09, 0x09, 0x09, 0x06} // 50 P,{0x3e, 0x41, 0x51, 0x21, 0x5e} // 51 Q,{0x7f, 0x09, 0x19, 0x29, 0x46} // 52 R,{0x46, 0x49, 0x49, 0x49, 0x31} // 53 S,{0x01, 0x01, 0x7f, 0x01, 0x01} // 54 T,{0x3f, 0x40, 0x40, 0x40, 0x3f} // 55 U,{0x1f, 0x20, 0x40, 0x20, 0x1f} // 56 V,{0x3f, 0x40, 0x38, 0x40, 0x3f} // 57 W,{0x63, 0x14, 0x08, 0x14, 0x63} // 58 X,{0x07, 0x08, 0x70, 0x08, 0x07} // 59 Y,{0x61, 0x51, 0x49, 0x45, 0x43} // 5a Z,{0x00, 0x7f, 0x41, 0x41, 0x00} // 5b [,{0x02, 0x04, 0x08, 0x10, 0x20} // 5c
  8. Like
    SirZusa got a reaction from bluehash in Content driven AmbientLight /// LightPack-Clone   
    Hey, i once again made some changes to the pcb.
     
    - thicker power-traces
    - less traces between pads
    - less vias
    - more spacing where possible
     
    i attached the brd-file so you can have a look on it, change it and do whatever you want - except commercial usage
     
    hmmm... i did not think about a name till now. i dont want to use AmbiLight because of the name (philips) :crazy:
     
    @bluehash - i did not send it to fabrication for now because i want a second layout on it for another project so i can save some

    LightPackClone v1.brd
  9. Like
    SirZusa reacted to oPossum in Software async serial tx/rx without timer   
    Had some requests for this in IRC so here it is. This is an improved version of the serial tx previously posted and new serial rx code. Both tx and rx are blocking and interrupts should be disabled before calling.
     
    C code to show how to use the serial_setup(), putc(), puts(), and getc() functions.
    This will receive a character, increment it and echo it back. So if you type 'A', then 'B' will be echoed.

    // test.c #include "msp430g2211.h" // Functions in serial.asm (this really should be in a header file) void serial_setup(unsigned out_mask, unsigned in_mask, unsigned duration); void putc(unsigned); void puts(char *); unsigned getc(void); void main(void) { char c; // Disable watchdog WDTCTL = WDTPW + WDTHOLD; // Use 1 MHz DCO factory calibration DCOCTL = 0; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; // Setup the serial port // Serial out: P1.1 (BIT1) // Serial in: P1.2 (BIT2) // Bit rate: 9600 (CPU freq / bit rate) serial_setup(BIT1, BIT2, 1000000 / 9600); // Send a string puts("\r\nRunning...\r\n"); for(; { // Do forever c = getc(); // Get a char ++c; // Increment it putc(c); // Echo it back } }
     
    The serial tx/rx code. Just add this as a new source file in your CCS project and it will be callable from your C code.

    ; serial.asm .cdecls C, LIST, "msp430g2231.h" .bss in_bit_mask, 2 ; Serial in pin .bss out_bit_mask, 2 ; Serial out pin .bss bit_dur, 2 ; Bit duration in cycles .bss half_dur, 2 ; Half bit duration in cycles ; .text ; .def serial_setup ; void serial_setup(unsigned out_mask, unsigned in_mask, unsigned bit_duration); .def putc ; void putc(unsigned c); .def puts ; void puts(char *s); .def getc ; unsigned getc(void); ; ; serial_setup ; - Setup serial I/O bitmasks and bit duration (32 minimum) mov R12, &out_bit_mask ; Save serial output bitmask mov R13, &in_bit_mask ; Save serial input bitmask bis.b R12, &P1DIR ; Setup output pin bis.b R12, &P1OUT ; bic.b R13, &P1DIR ; Setup input pin or R13, R12 ; bic.b R12, &P1SEL ; Setup peripheral select mov R14, R12 ; sub #16, R14 ; Adjust count for loop overhead rla R14 ; Multiply by 2 because NOP is two bytes mov R14, &bit_dur ; Save bit duration sub #32, R12 ; Adjust count for loop overhead mov R12, &half_dur ; Save half bit duration ret ; Return ; ; - Send a single char putc ; Char to tx in R12 ; R12, R13, R14, R15 trashed mov &out_bit_mask, R15 ; Serial output bitmask mov &bit_dur, R14 ; Bit duration or #0x0300, R12 ; Stop bit(s) jmp bit_low ; Send start bit... ; tx_bit mov R14, R13 ; Get bit duration tx_delay nop ; 4 cycle loop sub #8, R13 ; jc tx_delay ; subc R13, PC ; 0 to 3 cycle delay nop ; 3 nop ; 2 nop ; 1 ; rra R12 ; Get bit to tx, test for zero jc bit_high ; If high... bit_low bic.b R15, &P1OUT ; Send zero bit jmp tx_bit ; Next bit... bit_high bis.b R15, &P1OUT ; Send one bit jnz tx_bit ; If tx data is not zero, then there are more bits to send... ; ret ; Return when all bits sent ; ; ; - Send a NULL terminated string puts ; Tx string using putc push R11 ; mov R12, R11 ; String pointer in R12, copy to R11 putsloop ; mov.b @R11+, R12 ; Get a byte, inc pointer tst.b R12 ; Test if end of string jz putsx ; Yes, exit... call #putc ; Call putc jmp putsloop ; putsx pop R11 ; ret ; ; getc ; - Get a char mov &bit_dur, R14 ; Bit duration mov &in_bit_mask, R13 ; Input bitmask mov #0x01FF, R12 ; 9 bits - 8 data + stop ; rx_start ; Wait for start bit mov.b &P1IN, R15 ; Get serial input and R13, R15 ; Mask and test bit jc rx_start ; Wait for low... ; mov &half_dur, R13 ; Wait for 1/2 bit time ; rx_delay nop ; Bit delay sub #8, R13 ; jc rx_delay ; subc R13, PC ; 0 to 3 cycle delay nop ; 3 nop ; 2 nop ; 1 ; mov.b &P1IN, R15 ; Get serial input and &in_bit_mask, R15 ; rrc R12 ; Shift in a bit ; mov R14, R13 ; Setup bit timer jc rx_delay ; Next bit... ; rla R12 ; Move stop bit to carry swpb R12 ; Move rx byte to lower byte, start bit in msb ret ; Return with rx char and start bit in R12, stop bit in carry ; .end ;
  10. Like
    SirZusa reacted to rockets4kids in Very Lucid MSP430 Documentation   
    I recently stumbled across some MSP430 documentation that does not seem to be linked from anywhere on their site. It appears to be rather old, but that is actually rather helpful as it documents just the core features of the MSP430 common to all chips and it is much more readable than the current Family Guides.
     
    "MSP430 Family Architecture Guide and Module Library"
     
    http://www.ti.com/sc/docs/products/micr ... /ag_01.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_02.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_03.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_04.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_05.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_06.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_07.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_08.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_09.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_10.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_11.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_12.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_13.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_14.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_15.pdf
    http://www.ti.com/sc/docs/products/micr ... /ag_16.pdf
    http://www.ti.com/sc/docs/products/micr ... d/ag_a.pdf
    http://www.ti.com/sc/docs/products/micr ... d/ag_b.pdf
    http://www.ti.com/sc/docs/products/micr ... d/ag_c.pdf
     
    "MSP430 Family" - a guide to assembly programming for the MSP430
     
    http://www.ti.com/sc/docs/products/micr ... d/as_1.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_2.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_3.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_4.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_5.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_6.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_7.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_8.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_9.pdf
    http://www.ti.com/sc/docs/products/micr ... /as_10.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_a.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_b.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_c.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_d.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_e.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_f.pdf
    http://www.ti.com/sc/docs/products/micr ... d/as_g.pdf
    http://www.ti.com/sc/docs/products/micr ... /as_in.pdf
    http://www.ti.com/sc/docs/products/micr ... /as_pr.pdf
     
    There are a few other files in this directory, but nothing particularly noteworthy.
  11. Like
    SirZusa reacted to leomar01 in UART TX on Port2.0 for bigger value line devices   
    After many hours of struggling with datasheets, reading code samples, getting grace to work, asking a lot in this forum and getting much help, I finally got the SW UART on Port2.0 working (TX only - for now).
    /*####################################### This is one more way of a software uart, but on port2.0 for the 20pdip MSP430s.
    I have used many parts from here and there, but most of this code is generated in grace
    and afterwards slightly modified to achieve the goal of a software uart on port2.0
     
    My MSP430G2553 runs on 16MHz, if you want to use an other clockspeed, you have to adjust the bittime
     
    for suggestions and complaints, please feel free to contact me on 43oh.com
    leomar01
     
    */
     
    #include
     
    void putstr(char *str); // transmit string
    void transmit(unsigned char ch); // transmit a character
    void setup(void); // function for setting up the device
     
     
    #define BITIME (13 * 16) // prescaler: 8 -> 2 MHz /(13*8*2) = 9600 bits/sec
     
    unsigned char bitCnt; // number of bits to transmit
    unsigned int txByte; // transmit buffer with start/stop bits
     
    void setup(void)
    {
    BCSCTL1 = CALBC1_16MHZ;
    DCOCTL = CALDCO_16MHZ;
     
    /* Port 2 Output Register */
    P2OUT = 0;
     
    /* Port 2 Port Select Register (see page 50 in datasheet -> port2.0 will be Timer1_A3.TA0) */
    P2SEL = BIT0;
     
    /* Port 2 Direction Register */
    P2DIR = BIT0;
     
    /* Port 2 Interrupt Edge Select Register */
    P2IES = 0;
     
    /* Port 2 Interrupt Flag Register */
    P2IFG = 0;
     
    /* Configure Timer1 (See Users Guide page 374) */
    TA1CCTL0 = CM_0 + CCIS_0 + OUTMOD_0 + CCIE + OUT;
    TA1CCR0 = 1200;
    /* users guide page 372 -> clock source: SMCLK, input divider: 8, mode control: continuous up to 0xFFFF */
    TA1CTL = TASSEL_2 + ID_3 + MC_2;
    __bis_SR_register(GIE); // enable GIE in status register
    }
     
    void putstr(char *str)
    {
    char *cp;
    for (cp = str; *cp != '\0'; cp++) {
    transmit(cp[0]);
    }
    }
     
    void transmit(unsigned char ch)
    {
    bitCnt = 0xA; // Load Bit counter, 8data + ST/SP
    txByte = (unsigned int)ch | 0x100; // Add mark stop bit to txByte
    txByte = txByte << 1; // Add space start bit
     
    TA1CCR0 = TA1R + BITIME; // Some time till first bit
    TA1CCTL0 = OUTMOD0 + CCIE; // TXD = mark = idle
    while (TA1CCTL0 & CCIE); // Wait for ISR to complete TX
    }
     
     
    void main(){
    WDTCTL = WDTPW|WDTHOLD; // Stop watchdog timer
    // Kalibrierdaten f
  12. Like
    SirZusa got a reaction from dacoffey in Content driven AmbientLight /// LightPack-Clone   
    Idea and description:
    Inspired by this project (Lightpack: http://code.google.com/p/light-pack/) i started to develop my own solution based on an launchpad equipped with a MSP430G2211, later i had to move on to a MSP430G2553 cause i was runnning out of RAM. Now it makes use of the hardware-UART and can theoretically handle up to 375 frames per second.
     
    How to take control over the
  13. Like
    SirZusa got a reaction from pillum in TLC5940 - "Full Implementation"   
    hi there, as i already said in another thread i was working on the code for controlling the TLC5940. here it is!
     
    100% working. specification-sheet i used to code this: http://www.ti.com/lit/sw/slvc106/slvc106.pdf
     


    [*:1o0bnvvd]supports DC
    [*:1o0bnvvd]supports Grayscale
    [*:1o0bnvvd]recommendet implementation from the Programming Flow Chart
    [*:1o0bnvvd]does not support EEPROM-programming (cause you will need 22 Volts for this)
    [*:1o0bnvvd]actually does not support "Use DC from EEPROM-mode"
    [*:1o0bnvvd]LOD-Check not implemented for now ... but i think i will do this soon if i find more literature on this
     

    /*** TLC5940 ***/ #include "msp430g2553.h" #include "stdbool.h" // How many TLC's daisy-chained #define n 2 /*** Ports ***/ // STATUS-LED #define PORT_STATUS_LED P1OUT #define PIN_STATUS_LED BIT0 // BLANK - to pin 23 of every TLC5940 #define PORT_BLANK P1OUT #define PIN_BLANK BIT3 // XLAT - to pin 24 of every TLC5940 #define PORT_XLAT P1OUT #define PIN_XLAT BIT4 // SCLK - to pin 25 of every TLC5940 #define PORT_SCLK P1OUT #define PIN_SCLK BIT5 // SIN - to pin 26 of first TLC5940 #define PORT_SIN P1OUT #define PIN_SIN BIT6 // GSCLK - to pin 18 of every TLC5940 #define PORT_GSCLK P1OUT #define PIN_GSCLK BIT7 // DCPRG - to pin 19 of every TLC5940 #define PORT_DCPRG P2OUT #define PIN_DCPRG BIT3 // VPRG - to pin 27 of every TLC5940 #define PORT_VPRG P2OUT #define PIN_VPRG BIT4 /*** DO NOT EDIT BELOW ***/ #define x (n * 16) /*** Brightness-Correction ***/ const int pwm_table[256] = { 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,26,28,30,32,34,36,38,40,42, 44,46,48,50,52,55,58,61,64,67,70,73,76,79,82,85,88,91,94,97,100,103,106,110,114,118,122,126,130, 134,138,142,146,150,154,158,162,166,170,174,178,182,186,190,195,200,205,210,215,220,225,230,235, 240,245,250,255,260,265,270,275,280,285,290,297,304,311,318,325,332,339,346,353,360,367,374,381, 388,395,402,409,416,423,430,437,444,451,458,467,476,485,494,503,512,521,530,539,548,557,566,575, 584,593,602,611,626,641,656,671,686,701,716,731,746,761,776,791,806,821,836,851,866,881,896,916, 936,956,976,996,1016,1036,1056,1076,1096,1116,1136,1156,1176,1196,1221,1246,1271,1296,1321,1346, 1371,1396,1421,1446,1471,1496,1526,1556,1586,1616,1646,1676,1706,1736,1766,1796,1826,1856,1886, 1921,1956,1991,2026,2061,2096,2131,2166,2201,2236,2271,2306,2341,2376,2411,2446,2481,2516,2551, 2586,2621,2656,2691,2726,2761,2796,2832,2868,2904,2940,2976,3012,3048,3084,3120,3156,3192,3228, 3266,3304,3342,3380,3418,3456,3494,3532,3572,3612,3652,3692,3737,3782,3827,3872,3917,3962,4007,4095 }; // holds the actual DC-data for each channel char dc_data[x] = {63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63}; /*** Variables ***/ // first PWM-cycle after Dot Correction Data has changed? bool FirstCycleFlag; // holds the actual PWM-data for each channel int gs_data[x]; /*** small userdefined Functions ***/ // useful macros #define setLow(port, pin) { port &= ~pin; } #define setHigh(port, pin) { port |= pin; } #define pulse(port, pin) { setHigh(port, pin); setLow(port, pin); } #define toggle(port, pin) { port ^= pin; } /*** transfer DC-data to our TLC5940's ***/ void send_DC() { // DCPRG - dont use DC-EEPROM setHigh(PORT_DCPRG, PIN_DCPRG); // VPRG - set Dot Correction Input setHigh(PORT_VPRG, PIN_VPRG); // Reset Counter int Counter = 0; // clock in Dot Correction Data for (; { // Counter > n * 96 - 1 // 6 Bits * 16 Channels = 96 if (Counter > (n * 96 - 1)) { pulse(PORT_XLAT, PIN_XLAT); break; } else { // Set SIN to DC Data[Counter] // MSB first if ((dc_data[Counter / 6] >> (5 - (Counter % 6))) & 0x01) { setHigh(PORT_SIN, PIN_SIN); } else { setLow(PORT_SIN, PIN_SIN); } pulse(PORT_SCLK, PIN_SCLK); Counter++; } } // dont save to EEPROM - so we finish here // set FirstCycleFlag to true FirstCycleFlag = true; } /*** transfer PWM-data to our TLC5940's ***/ void send_GS() { if (FirstCycleFlag == true) { setLow(PORT_VPRG, PIN_VPRG); } // Reset Counters int GSCLK_Counter = 0; int Data_Counter = 0; setLow(PORT_BLANK, PIN_BLANK); // clock in PWM Data for (; { if (GSCLK_Counter > 4095) { setHigh(PORT_BLANK, PIN_BLANK); pulse(PORT_XLAT, PIN_XLAT); if (FirstCycleFlag == true) { pulse(PORT_SCLK, PIN_SCLK); } FirstCycleFlag = false; break; } else { // 12 Bit * 16 Channels = 192 if (Data_Counter > (n * 192 - 1)) { pulse(PORT_GSCLK, PIN_GSCLK); GSCLK_Counter++; } else { // Set SIN to GS Data[Counter] // MSB first if ((gs_data[Data_Counter / 12] >> (11 - (Data_Counter % 12))) & 0x01) { setHigh(PORT_SIN, PIN_SIN); } else { setLow(PORT_SIN, PIN_SIN); } pulse(PORT_SCLK, PIN_SCLK); Data_Counter++; pulse(PORT_GSCLK, PIN_GSCLK); GSCLK_Counter++; } } } } /*** Our main program ***/ void main(void) { // stop WDT - WDTPW is the password needed for every write and then tell watchdog to hold WDTCTL = WDTPW | WDTHOLD; BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; // initialize the ports connected to the TLC's // set ports to output-direction P1DIR |= (PIN_STATUS_LED|PIN_BLANK|PIN_XLAT|PIN_SCLK|PIN_SIN|PIN_GSCLK); P1OUT = 0x00; P2DIR |= (PIN_DCPRG|PIN_VPRG); P2OUT = 0x00; // initialize TLC5940 setLow(PORT_GSCLK, PIN_GSCLK); setLow(PORT_SCLK, PIN_SCLK); setLow(PORT_DCPRG, PIN_DCPRG); setHigh(PORT_VPRG, PIN_VPRG); setLow(PORT_XLAT, PIN_XLAT); setHigh(PORT_BLANK, PIN_BLANK); // force first cycle send_DC(); send_GS(); // enable interrupts __bis_SR_register(GIE); while(1) { // load gs-data here // update PWM-data permanently send_GS(); } }
  14. Like
    SirZusa got a reaction from leomar01 in Change pin of software UART   
    then have a look at the following part of your code - this is where the pin gets toggled (line 11 + line 13) - toggle pin 2.0 where it says // Set TX bit to 0
     
    you can also have a look at: http://320volt.com/wp-content/uploads/2 ... 400.c.html
    he has TX on the 1.5 - i can't test actually because i am not at home
     

    if(!isReceiving) { CCR0 += Bit_time; // Add Offset to CCR0 if ( BitCnt == 0) // If all bits TXed { TACTL = TASSEL_2; // SMCLK, timer off (for power consumption) CCTL0 &= ~ CCIE ; // Disable interrupt } else { CCTL0 |= OUTMOD2; // Set TX bit to 0 if (TXByte & 0x01) CCTL0 &= ~ OUTMOD2; // If it should be 1, set it to 1 TXByte = TXByte >> 1; BitCnt --; } }
  15. Like
    SirZusa got a reaction from leomar01 in Change pin of software UART   
    ahh now i see ... you use the 2553 - then you dont need software UART! it has hardware UART onboard - but on the Pins 1.1 and 1.2 do you really need it on Port 2.0? Otherwise i would advice you to use the hardware UART - it is faster, more stable, needs less space - and at least easier to use
     
    for the msp430g2553:
    P1.1 = RX
    P1.2 = TX
    if you use UART over the launchpad you will have to switch the jumpers that connect your
  16. Like
    SirZusa got a reaction from Theshadowwalker91 in Brake Signal Light   
    try something like:
     

    // when P1.1 LOW AND P1.2 HIGH then ... if(!(P2IN & BIT1) && (P2IN & BIT2)) { ... } // OR if((P2IN & ~BIT1) && (P2IN & BIT2)) { ... }
     
    should both do the same
  17. Like
    SirZusa reacted to oPossum in Compact async serial tx   
    Uses software delay loop instead of timer [interrupt] for small code size.
    Minimum bit duration is 18 clock cycles. One cycle granularity.
    I think this code is optimal (can not be done with fewer instruction words or cycles).
     

    tx_char ; Char to tx in R14 ; R10, R11, R12, R15 trashed mov #65553 - 104, R10 ; Bit duration (18 minimum) mov #0x02, R15 ; Serial output bitmask mov #10, R12 ; 10 bit times (may be reduced to 9 at high bit rates) bic.b R15, &P1OUT ; Start bit or #0xFF00, R14 ; Stop bit(s) nop ; bit_loop mov R10, R11 ; Get bit duration bit_time nop ; 4 cycle loop add #4, R11 ; jnc bit_time ; rla R11 ; 0 to 3 cycle delay add R11, PC ; nop ; nop ; nop ; rrc R14 ; Get bit to tx jc bit_high ; If high... bic.b R15, &P1OUT ; Send zero bit dec R12 ; Dec bit count jmp bit_loop ; Next bit... bit_high bis.b R15, &P1OUT ; Send one bit dec R12 ; Dec bit count jnz bit_loop ; Next bit... ret ; Return when all bits sent
  18. Like
    SirZusa got a reaction from bluehash in Content driven AmbientLight /// LightPack-Clone   
    Hey, i plan to write my software for 2 TLC's ... 32 LED's ... 10x RGB + 2 white LED's (or maybe ultraviolet???)
     
    actually i drive exactly this configuration with up to 400 fps !!! (enough for my next project ) :roll: but without scanning the pixels of the desktop ... this takes from 20 up to 100 ms on a modern computer ... depending on the resolution ... cpu ... and also OS ... win 7 with aero-effects is a real performance-badass
     
    so ... lets say you want at minimum 50 fps ... so it should be possible to use up to 16 TLC's ... 256 PWM-outputs at a refresh-rate of 50 fps ... WOW ... without the part off scanning the desktop ... but maybe for programming an effect-matrix or whatever
     
    i think this is the absolute maximum now ... so i will go on to the next part - scanning the desktops pixels and set the right color for each LED
     
    here's a video of the latest version (sorry for bad quality - i dont have a HD-cam :!!!: ):


  19. Like
    SirZusa got a reaction from bluehash in Content driven AmbientLight /// LightPack-Clone   
    Yeah! My RGB-LED's have arrived today (CREE-CLV6A)
     
    i have altered the Code a bit more as i already said:
    - deleted setFrequency - use calibrated DCO instead
    - using Hardware-UART
    - connectionspeed: 128.000 baud (using an old Nokia CA-42 cable)
    - new Brightness-Table
    - now i get up to 64 frames per second - wow - more than we need ... but i can do more - actually i send byte by byte ... i will try to send more than one byte a time - lets say for changing the colors an Array of 1 + 32 + 1 bytes / string with a length of 34 characters
     
    - 2 TLC's connected to the MSP430G2553 (on Launchpad) as usual
    - 100 nF between each GND and Vcc of the TLC
    - i will create the schematics later
     
    - some more details on controlling the

  20. Like
    SirZusa got a reaction from greeeg in Content driven AmbientLight /// LightPack-Clone   
    Idea and description:
    Inspired by this project (Lightpack: http://code.google.com/p/light-pack/) i started to develop my own solution based on an launchpad equipped with a MSP430G2211, later i had to move on to a MSP430G2553 cause i was runnning out of RAM. Now it makes use of the hardware-UART and can theoretically handle up to 375 frames per second.
     
    How to take control over the
  21. Like
    SirZusa got a reaction from gwdeveloper in Content driven AmbientLight /// LightPack-Clone   
    Idea and description:
    Inspired by this project (Lightpack: http://code.google.com/p/light-pack/) i started to develop my own solution based on an launchpad equipped with a MSP430G2211, later i had to move on to a MSP430G2553 cause i was runnning out of RAM. Now it makes use of the hardware-UART and can theoretically handle up to 375 frames per second.
     
    How to take control over the
  22. Like
    SirZusa reacted to bluehash in TLC5940   
    you can use __delay_cycles() instead of the macro.
×
×
  • Create New...