Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

difficult software problem

Altera_Forum
Honored Contributor II
980 Views

hello, 

 

i use QUARTUS 5.0 NIOS 5.0 

 

 

i have a difficult software problem, i think something is writing undefined 

into memory, but i cannot find it (searching now for two days). 

 

in the main function i have the following... 

 

main() { 

int ctime=0; 

int ctimemax=0; 

 

while(1) { 

... 

... 

if(....) { 

ctimemax=1000; 

else { 

ctimemax=5000; 

if(ctime>ctimemax) { // at this point ctimemax is e.g. 0 or something undefined 

.... 

... 

 

i have seen that the register fp (which is used to access ctimemax,stw r2,20(fp), 

is different from startup, when the error happens.  

the main problem is, that if i insert or renmove some code elsewhere,  

i cannot see the error again. 

 

one problem i have seen is that i made a fault with timer interrupts,  

but i don't know if this could cause the error. 

 

i had a# define 

# define ALARMTICKS(x) ((alt_ticks_per_second()*(x))/1000) 

 

DWORD alarm_spst_callback_10ms (void* context) { 

 

alarmflags|=ALARM_SP_10MS; 

if(led_txrx_time>0) { 

led_txrx_time--; 

PIO_CBI(PIO_LED_BASE,LED_TX_RX); 

else { 

PIO_SBI(PIO_LED_BASE,LED_TX_RX); 

if(dsptimeout) dsptimeout--; 

 

return ALARMTICKS(10); 

 

this inserted a multiplication and division in the interrupt 

 

... 

0x00806874 <alarm_spst_callback_10ms+160>: call 0x80c524 <__mulsi3> 

0x00806878 <alarm_spst_callback_10ms+164>: mov r4,r2 

0x0080687c <alarm_spst_callback_10ms+168>: movi r5,1000 

0x00806880 <alarm_spst_callback_10ms+172>: call 0x80c504 <__udivsi3> 

... 

 

i changed this to get a constant for the return value,  

i cannnot see the error in the main loop again, 

but i think this was not the problem 

 

could the multiplication and division in the interrupt cause my problem ? 

any suggestions, how i can find this error ? 

i have seen that there is now "Run time stack checking", how does it works? 

 

thanks
0 Kudos
0 Replies
Reply