This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

byte on output pin

Other Parts Discussed in Thread: MSP430F5438A

is there a way to clock out 8bit stream into one output pin without using any delay or clock delay?

just like when you put 8bit stream into  spi slave transfer buffer,8 bits clock out on SOMI pin nicely.

  • Moon Kim said:
    is there a way to clock out 8bit stream into one output pin without using any delay or clock delay?
    just like when you put 8bit stream into  spi slave transfer buffer,8 bits clock out on SOMI pin nicely.

    You answered yourself. THe SPI hardware is exactly what you want.
    In slav emdoe, it shifts the bits out based on external clock, in master mode based on internal clock. If oyu jus twant the output, you don't need the SIMO pin in slave mode and not even the clock pin in master mode.

    If you need a lower frequency, you can do the same by the timer CCR units and additional software effort: set up the CCR unit to change its output at a certain tiemr count and trigger an interrupt. In the interrupt you reporgram the CCR unit for the next tiemr count and the next output level. The software UART in teh LaunchPad demo software works this way.

  • thank you for reply but my problem is that I want to output 8bits which I receive from SPI bus to different pins at different timing( in sequence).

    In other words, I want to have multiple pins that work like SOMI pin.

     

  • Some MSP430 members have multiple serial peripherals.

  • Well obviously if you want the convenience of writing a byte value to some register and have it clocked out nicely just like an SPI output, then you need to use the hardware capability that's provided by the chip (well, SPI or perhaps UART or I2C if you can work with them). If you can't use a hardware module cause you're already using it then you're left with coding the functionality yourself. An example could be something like this:

    volatile unsigned int byValue = 0x00; //# byte value to send
    void main(void) {
        //# we'll be using DCO clock and scaling it to 8MHz for MCLK and SMCLK
        BCSCTL1 = CALBC1_8MHZ;
        DCOCTL = CALDCO_8MHZ;

        //# configuring timerA
        TACCTL0 = ~CCIE;
        TACCR0 = 500; //# we'll be running the timer on 1MHz and so to get about 1kHz waveform we'll need to count to about 500 before toggling the pin (full period is toggling the pin twice)
        TACTL = TASSEL_2 + MC_1 + ID_3; //# using SMCLK which is 8MHz, counting up to TACCR0 value and dividing the clock by 8 to get 1MHz
        __enable_interrupt(); //# enable interrupts.

        TACCTL0 = CCIE; //# switching on the timer
    }

    #pragma vector=TIMER0_A0_VECTOR
    __interrupt void Timer_A (void) {

        if ((byValue & 0x1)==0) {
            P2OUT &= ~BIT3;
        } else {
            P2OUT |= BIT3;
        }

        byValue = byValue << 1;
    }


    Of course you need to configure your ports right and include the correct header for your device but largely this will now put out your bit stream on PORT2, BIT3 as soon as you write anything to byValue. You also may want to disable the timer when you don't need anything shifted out on the PORT2.3 but that's your homework. And yeah the bit stream will come out at 1kHz.

  • Moon Kim said:
    In other words, I want to have multiple pins that work like SOMI pin.

    Then us an MSp that has multiple SOMI pins. The MSP430F5438A has 4 USCI modules and up to 8 simultaneous SPI modules. With eight pins acting 'like SOMI' (because they are).

    Or you do it in software.

  • Using software using interrupts looks promising  in this case. Unless MCU is heavily used in other tasks too.

**Attention** This is a public forum