AVR32 program crashes when variable is read - v strange prob

Status
Not open for further replies.

sebmaster

Member level 1
Joined
Mar 9, 2008
Messages
38
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,286
Activity points
1,719
Hello,

In the program for my AVR32 I have a state machine, within this state machine there is the case:

Code:
case  	10:
	usart_putchar(usart,ACK);
	graphicsSetLVDStxEnable(currentLVDS);
	currentLVDS = currentMemoryBank;

	state = 1;
	break;

This code works at the moment (currentMemoryBank is just another variable used to prove a point), however should I add any code which causes the variable currentLVDS to be given a new value based on itself, for example:

Code:
	if(currentLVDS)
		currentLVDS = 0;
	else
		currentLVDS = 1;

or:
Code:
currentLVDS = (int)(currentLVDS == 1);

It freezes up on the second execution of that case.

I have determined it freezes up after a long session of placing various breakpoints around and trying different bits of code because the debugger just exits with an error "bad file descriptor" and no more information.

I'm at a loss for words with this one, anyone seen anything like it?

EDIT: The variable is within scope and its not a pointer/reference or anything of the sort. The code is a word-for-word copy of another lot within the same state machine that works fine, just with one variable and one function name changed.

I know the function isnt causing the problem because if I rewrite this section to assign currentLVDS anything but a function of itself, it works fine indefinately through multiple calls.

Also:
Code:
			currentLVDS2 = currentLVDS;
			currentLVDS = (int)(!currentLVDS2);
Works just fine.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…