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.

Accessing SFR registers & Instruction cycle time

Hi all,

 

I am new to MSP 430 .Now i have one doubt whether  the SFR registers in MSP 430 is bit accessible or not?

and one more doubt,if i use SMLCK  with the DCO Frequency of 1MHz  means what is the instruction cycle time?

the code as follows

while(1)

{

P1OUT=0X01;

P1OUT=0X00;

}

For the above program from high to low i got 4uS.but as per calculation i have to get 1uS.

what is the problem with  the program?

 

thanks in advance.

  • SMCLK has nothing to do with CPU cycles.

    If you are using C, do not try to count CPU cycles.

     

  • It's always interesting how two supposedly different people can ask exactly the very same question within 24hrs:

    Ashok kumar Karnan said:
    i am new to MSP430.Now i want to know the instruction execution time of MSP 430.I am using SMCLK with the frequency of 1MHz.and my program is as follows..

    while(1)
    {
    P1OUT=0x00;
    P1OUT=0x01;
    }
    for the the above program what is instruction execution time?
    i got 4us .Is it correct?
    As per calculation we get 1us then why this 4uS?

    It really smells like some university professor has given his students a new task. He really should teach them using the search function first, if they really need to ask for help in a forum.

    See my answer to this here.

    About the SFR: what do you mean with 'bit accessible'?
    The good old 8032 did have special opcodes which addressed the first 16 bytes of its addressing range as if they were an array of 256 bits. This was bit-addressible I/O. The MSP doesn't have this.
    You cannot change/write a single bit in a register (including the SFR) without reading the whole register before. However, the MSPs RMW (read-modify-write) operations allow you to change individual bits of a 8 or 16 bit register without touching the other bits. However, a read is necessary. However, some (but not all!) registers can be read byte- and word-wise. It eeosn't make a difference, as both require one read and one write cycle.

    p.s.: try 'P1OUT=0x80' instead (preceded by a P1DIR=0x80 of course). You'll be surprised. The explanation is in the CPU section of the users guide.

  • Thanks for your reply.

    i am also use pic microcontroller.

    in pic microcontroller  if i use 4Mhz then instruction execution time is 1uS.

    for the program

    while(1)

    {

    RB0=0;

    RB0=1;

    }

    then the low to high time is 1uS.

    and also in SFR register many registers are bit accessible .

    For example

    PORTB is 8 bit Port Register.You can access each bit as follows

    RB0=1;

    RB1=0;

    RB2=1;. .........etc

     

     

     

     

  • Joseph Christober said:
    i am also use pic microcontroller.

    I had to work with these bastards too. Luckily no more.

    Joseph Christober said:
    in pic microcontroller  if i use 4Mhz then instruction execution time is 1uS.

    For several reasons.

    First, the PIC does not use von-Neumann-structure. Code and data have their own data and address bus. Also, there is a dedicated hardware stack.

    This allows instrucitons to be better pipelined, as code memory and data can be read in the same cycle.
    However, the PIC core does by far not offer all the things the MSP core can. And while this exact example might indeed by 1 cycle per instruction on teh PIC, the compiler will have to generate far more instructions for the same typical code than on MSP.  So "1 cycle per instruction" is a nice advertizing statement. Yet the far worse 'instructions per average C statement' ratio relativates this.

    There are 1-cycle- instructions on the MSP, but not if access to memory is required (including the memory-mapped hardware registers), like the ports.

    Joseph Christober said:
    You can access each bit as follows
    RB0=1;


    Yes. This does, however, require a special hardware mapping of the bits on the address and data bus. And is incompatible with a von Neumann architecture. And does not allow for a modular structure of CPU and peripherals.
    You can simulate it on the MSP by using C bitfields. The compiler will then generate code that does what you want. It is, however, very inefficient as soon as more than one bit needs to be manipulated. Using RMW operations is a bit slower on a single bit, but catches up as soon as more than one bit needs to be manipulated.

     

**Attention** This is a public forum