Jump to content
43oh

jmparatte

Members
  • Content Count

    11
  • Joined

  • Last visited

Posts posted by jmparatte

  1. Today, I've received my new LaunchPad MSP-EXP430F5529LP. The W8.1x64 MSP430 Application UART works like a charm...

    Apparently same with OpenWrt /dev/ttyACMx. No sorrry, the serial hangs after a couple of minutes ! (verified many times)

  2. Many thanks to spirilis,

     

    I confirm the "do not send any characters before open the driver". I can add it's the same to close the driver.

    My configuration is LaunchPad msp430g2 connected to TL-MR3020 freshly flashed with OpenWrt attitude, and associative packages.

    I've used picocom to connect to /dev/ttyACM0 and do checks. The msp430 program sends a character every seconds.

     

    So I've connected like that:

     

    1/ Maintain pressed the Reset button of msp430 LaunchPad.

    2/ Connect the LaunchPad to USB while maintaining Reset.

    3/ Start picocom /dev/ttyACM0

    4/ Observe that the message "Terminal ready" comes immediatly, else the driver is in error.

    5/ Release the Reset button of LaunchPad, the program starts.

     

    To close picocom and disconnect the LaunchPad from usb, it's alos important to do the same actions in another order:

     

    1/ Maintain pressed the Reset button of msp430 LaunchPad.

    2/ Close picocom (^a^x) while maintaining Reset.

    3/ Observe the quick exit of picocom, else the driver is in error.

    4/ Disconnect the LaunchPad from usb.

    5/ Release the Reset button.

     

    You can do same actions by removing the 2 RX/TX jumpers before connect/disconnect from usb/open/close/driver.

     

    2014-01-14: The OpenWrt Embedded Linux is unsafe! After a couple of minutes at 9600Bps, the driver hangs...

     

    jmP

  3. I'm developping some codes with Energia or TI CCS for the TI LaunchPad MSP-EXP430G2, v1.4 and v1.5, with G2553 and G2452 chips. I organize DIY workshops.

     

    I'm playing with various computers, I enumarate them: 1x W7Pro32, 1x W7Starter, 1x W8.1x64, 1x TP-Link TL-MR3020+OpenWrt, 1x TP-Link WR710N+OpenWrt.

     

    Nothing is going right with serial, only my old W7Pro32 can read/write thru the USB serial ! Even my 2 OpenWrt TP-Link can't communicate !

     

    If I play with some Arduino in place of TI LaunchPad, all USB serial is working fine (except the known reset problem of Arduino USB serial).

     

    Yesterday evening, I played a lot with a TI LaunchPad and my W8.1x64. I discovered that sometimes, the serial USB could communicate ! That's after a lot of stress of the serial settings. I used PuTTY to receive something. The G2553 program was continualy sending 1 character every second. After changing the "Flow control" in PuTTY/Settings/Connection/Serial a lot of times, changing from XON/XOFF to RTS/CTS to /DTR/DSR, in any order, and typing a lot of ^S,^Q,... sentences, the TI Launchpad would finally communicate ! As soon as the USB serial communicates, I can deselect the "Flow control" (can be any) to "none". But never unplug the USB else...

     

    What is wrong in the firmware ?

  4. Hi oPossum,

     

    Simplified inline functions push and pop as your propose are unfortunately not a good solution because the compiler doesn't follow the mormal rules of calling parameters and returns. The compiler (CCS 4.2) inserts the source of the inline function and makes a global optimization of the code, so doesn't systematically use R12 calling arguments and return, neither put CALL and RET.

     

    Your first solution which is to place a single asm("...") referring an external variable is interesting. In practice it's a little waste of codes because the foo referred variable must be a global variable. But this is a good solution if the regisgter R4 (or R5) isn't free. Thanks.

     

    jmP

  5. Moving from AVR and GCC compiler to MSP430 and CCS, I wish 2 new intrinsics like my old:

     

    static inline void PUSH (uint16_t u)
    {
    asm volatile (
    	"push %B0" "\n\t"
    	"push %A0" "\n\t"
    	:
    	: "r" (u)
    );
    }
    static inline uint16_t POP ()
    {
    uint16_t result;
    asm volatile (
    	"pop %A0" "\n\t"
    	"pop %B0" "\n\t"
    	: "=r" (result)
    );
    return result;
    }
    

     

    At moment, I've solved with:

    inline void PUSH (uint16_t u)
    {
    _set_R4_register(u);
    asm(" PUSH.W R4");
    }
    inline uint16_t POP ()
    {
    asm(" POP.W R4");
    return _get_R4_register();
    }
    

     

    I think it's inelegant because I need to use the register R4.

     

    Any idea with CCS 4.2 ?

     

    jmP

  6. I've made also some experimentations about clocking the G2231 with an external clock 16MHz.

     

    Before reading your code, I experimented a solution near yours, but with a little change: the ACLK is driven with an external clock and the MCLK is driven with the internal DCO. I will explain it far.

     

    First I tried your code. It works. See below my code test:

    void main (void)
    {
    WDTCTL = WDTPW + WDTHOLD;	// Stop watchdog timer
    
    BCSCTL3 = LFXT1S_3 | XCAP_0;	// Digital external 0.4- to 16-MHz clock source
    
    // Drive ACLK, MCLK & SMCLK with digital external clock source on XIN pin...
    // LFXT1CLK = Digital external clock = Quartz Pierce Oscillator = 16MHz
    // ACLK = LFXT1CLK/8 = 2MHz
    // MCLK = SMCLK = 16MHz
    DCOCTL = 0x00;					// Select lowest DCO and RMOD settings
    BCSCTL1 |= DIVA_3;				// ACLK/8
    BCSCTL2 = SELM_3 | DIVM_0 | SELS*1 | DIVS_0; // LFXT1CLK or VLOCLK
    BCSCTL3 = LFXT1S_3 | XCAP_0;	// Digital external 0.4- to 16-MHz clock source
    //
    // (Not sure if this is needed?) Yes, it's needed!
     while(IFG1 & OFIFG) {
    	IFG1 &= ~OFIFG;			// Clear OSCFault flag
    //		_delay_cycles(10000);	// Delay for flag and visibility (perhaps it's needed)
    }
    //
    __bis_SR_register(SCG0);	// Stop DCO. We just use LFXT1CLK which is actually 
    							// running with digital external clock source
    

    Comments:

    1/ The code

    while(IFG1 & OFIFG) {...}

    before

    __bis_SR_register(SCG0)

    seams to be necessary else it's like if an internal PLL takes a lot of time to synchronize with the external clock. I've observed that because the 1rst task (not described here) of my

    main(){...}

    procedure is to send a signature on the TXD pin, and some characters was wrong.

    2/ The code

    _delay_cycles(10000)

    doesn't seam to be necessary running with a 16MHz extrernal clock. Not sure if it's same running at other frequencies.

    3/ In my example, ACLK runs at 2MHz (LFXT1CLK/8).

    4/ I haven't found a TI documentation about

    __bis_SR_register(SCG0)

    to stop the internal VLO and take the external clock instead.

    5/ It seams that set XTS to "1" in the BCSCTL1 is not necessary. It's "0" in my example.

     

    So OK, it works like that.

     

    But here is another idea: Is it necessary to run MCLK with a precise frequency ?

    I answer NO and I can simplify the code with the 2 ideas:

    1/ Drive ACLK with a precise quartz external clock to clock the timer.

    2/ Drive MCLK with DCOCLK running at high frequency to clock the processor.

     

    My proposed code:

    void main (void)
    {
    WDTCTL = WDTPW + WDTHOLD;	// Stop watchdog timer
    
    // Clock after Reset, SMCLK = MCLK = ACLK = DCOCLK = ~1.1MHz:
    // DCOCTL:	0x60 (DCO_3, RMOD_0)
    // BCSCTL1:	0x87 (XT2OFF*1, XTS*0, DIVA_0, RSEL_7)
    // BCSCTL2:	0x00 (SELM_0, DIVM_0, SELS*0, DIVS_0)
    // BCSCTL3:	0x05 (XT2S_0, LFXT1S_0, XT2OF*0, LFXT1OF*1)
    // SR:	0x0003 (V*0, SCG1*0, SCG0*0, OSCOFF*0, CPUOFF*0, GIE*0, N*0, Z*1, C*1)
    // My MSP430G2331 has calibrated values:
    // CALDCO_1MHZ:	0xA8 (DCO_5, RMOD_8)
    // CALBC1_1MHZ:	0x86 (XT2OFF*1, XTS*0, DIVA_0, RSEL_6)
    
    // Set DCOCLK to calibrated 1MHz...
    //	DCOCTL = 0x00;					// Select lowest DCO and RMOD settings
    //	BCSCTL1 = CALBC1_1MHZ;			// Set range
    //	DCOCTL = CALDCO_1MHZ;			// Set DCO step + modulation
    
    // Set DCOCLK ~16MHz...
    DCOCTL = 0x00;					// Select lowest DCO and RMOD settings
    BCSCTL1 = XT2OFF*1 | XTS*0 | DIVA_0 | 14; //RSEL_0;	// Set range
    DCOCTL = DCO0*3 | 0; //DCO_3 | RMOD_0;	// Set DCO step + modulation
    
    // Drive ACLK with digital external clock source on XIN pin...
    // LFXT1CLK = Digital external clock = Quartz Pierce Oscillator = 16MHz
    // ACLK = LFXT1CLK/8 = 2MHz
    // MCLK = SMCLK = DCOCLK = ~16MHz
    BCSCTL1 |= DIVA_3;				// ACLK/8
    BCSCTL2 = SELM_0 | DIVM_0 | SELS*0 | DIVS_0; // DCOCLK 2x
    BCSCTL3 = LFXT1S_3 | XCAP_0;	// Digital external 0.4- to 16-MHz clock source
    

    Benefits are:

    1/ Smaller code.

    2/ Processor clocked immediately at high frequency and ready to use.

     

    jmP

×
×
  • Create New...