I have an EZ USB FX2LP development board and chip. I have come across a bug that I cannot explain. In my code I have working code, making a pwm, until I reworked it a little and the code stops execution completed on what appears to be a simple math statement. I have tested (with LEDS) and no code is executed after the line:
hightime = 290+(50 * stpt);
I am using the keil uvision2 ide/compiler with c to compile. Also, other math operations have worked fine in other code, and in this one. Any advice on why this is happening or how to fix it would be greatly appreciated. Thank You, Seth Kirk
Here is the code snippet: stpt = 18; //arbitrary start, will drive pick motor until 2nd enc edge //probably should be close to fulltilt if(PWM_CALC==0) {
if(PWM_HI_LO==0) { //going to be hightime next
hightime = FTIMER/FPWM - hightime;//calcs lowtime
} else if (PWM_HI_LO==1) {
hightime = 290+(50 * stpt); //code stops here
IOE = 0xF0; //turns on LEDs (not executed)
//if(hightime>65535) { hightime = 65535; } //overflow, shouldnt happen
}
buffer = (65535 - hightime)/(256);
bufferlow=(hightime-256*(255-buffer)); //start
if(bufferlow<=128) {
//IOE ^= 0x08; //toggle LED2
} PWM_CALC=1;