SAM4S/Atmel Studio and while problem

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

trs
Posts: 1
Joined: Fri Apr 24, 2015 12:46 pm

SAM4S/Atmel Studio and while problem

Fri Apr 24, 2015 1:01 pm

Hi

Dont know if this is the right forum, but I'm having problems with a while sentence.
Short snippet of code below. The second argument in the while sentence does not take effect...
I'm using Atmel studio 6.2

volatile UNS_8 Rautosend[5] = {0xFF,0xFF,0xFF,0xFF,0xFF};

void test(void)
{
unsigned int count = 0;

...
count = 0;
while ((Rautosend[count] == 0) && (count < 5))
count++;
data[0] = 0xAA; //Activate scenario
data[1] = 0XBB; //Activate scenario
...
}

Debbuging shows the following:
...
while ((Rautosend[count] == 0) && (count < 5))

0040CE0E ldr r3, #372
0040CE10 ldrb r3, [r3]
0040CE12 tst.w r3, #255
0040CE16 bne.w #1062
0040CE1A movs r6, #0
0040CE1C ldr r2, #356

count++;

0040CE1E adds r6, #1
0040CE20 ldrb r3, [r2, r6]
0040CE22 tst.w r3, #255
0040CE26 beq #500


data[0] = 0xAA; //Activate scenario
0040CE28 movs r3, #170
0040CE2A strb.w r3, [sp, #4]
data[1] = 0XBB; //Activate scenario
0040CE2E movs r3, #187
0040CE30 strb.w r3, [sp, #5]
...

As far as I can see and using step in the debugger when the Rautosend is filled with zeroes, the while does not end...
(count < 5) does not work. Any Ideas?
donjo9
Posts: 8
Joined: Wed Dec 10, 2014 12:36 pm

Re: SAM4S/Atmel Studio and while problem

Thu May 07, 2015 12:30 pm

When i started to work with my SAM4 , while and for loops didnt work properly, if i didnt use uint32_t as counter value type

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest