Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

msp430 cycle time problem

Status
Not open for further replies.

steve.hunch

Member level 1
Joined
Mar 8, 2011
Messages
40
Helped
8
Reputation
18
Reaction score
7
Trophy points
1,288
Location
Australia
Activity points
1,478
Hi ,
I use eval board "LaunchPad" I set CLK to 1MHz.
When I try to check the maximum on-off rate on one of the pins I get 10usec - 100KHz.
Doing just:

while(1)
{
P1OUT = 0;
P1OUT = 0xff;
}


The problem is that system clock is 1MHz, but this code gives my only 100kHz.
What can be a problem?

Changing clock to 10MHz, I get 1MHz at the I/O.
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,236
Helped
1,151
Reputation
2,321
Reaction score
1,127
Trophy points
1,403
Location
Brazil
Activity points
53,760
If you disassemble this C program into Assembly code, maybe will obtain the answer.
Each instruction and statement of code execute specific funcion and consumes instruction time.

+++
 

steve.hunch

Member level 1
Joined
Mar 8, 2011
Messages
40
Helped
8
Reputation
18
Reaction score
7
Trophy points
1,288
Location
Australia
Activity points
1,478
I did this, but apparently each each of those instructions disassembles to one assembler instruction. This means that I should get, at least for logical '0' approximate 1usec time (with 1MHz system clock).
But I still get 10usec. There is some factor of 10 in instruction execution...
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,236
Helped
1,151
Reputation
2,321
Reaction score
1,127
Trophy points
1,403
Location
Brazil
Activity points
53,760
while(1) -> Instruction that compare, and skip
{
P1OUT = 0; --> instruction that set output
P1OUT = 0xff; -> instruction that set output
} -> instruction that jump

Maybe there are other operations.
Try change optimization options.

+++
 

Sink0

Full Member level 6
Joined
Nov 25, 2009
Messages
390
Helped
37
Reputation
74
Reaction score
30
Trophy points
1,308
Location
Sao Paulo, Brazil
Activity points
4,186
No .. actually you are getting a good toggle speed on you output, but for sure with no 50% duty-cycle. Toggling a port on MSP430 does not take 1 instruction cycle. It can take 3 to 5 cycles, dpending from where your data is coming, and you got the added jump cycle from your while (i think that takes 3 cycles). Some other architectures have some special pin manipulation hardware. Always read the manual :) before chosing your architecture.. i always tell that to people that thinks that one architecture is perfect (as many does with ARM as an example). With a 50% duty cycle you would have to use xor instruction, and that woud take a total of 14 cycles for a full positive and negative edge. 3 from jump, and 4 from xor. There is no optimization that can handle hardware limitation.

Cya and GL
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top