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++
12596 Discussions

why the results i run or debug this code are different,your help would be appreciated

Altera_Forum
Honored Contributor II
906 Views

/* 

* control.c 

* Created on: 2012-11-15 

* Author: zhanghan 

*/ 

 

# include "alt_types.h"# include "altera_avalon_timer_regs.h"# include "sys/alt_irq.h"# include "system.h"# include <stdio.h># include <unistd.h> 

 

 

void timer_ISR(void); 

void init_spi(void); 

int d; 

 

 

int main(void) 

 

printf("\nWelcome!!!\n"); 

 

init_spi(); 

 

 

printf("\nSpi initial succeed!\n");  

 

 

while(1) 

return 0; 

 

 

void init_spi(void) 

d=0; 

IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE,0x00); 

// IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_BASE,25000>>16); 

// IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_BASE,25000 && 0xffff);  

IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_BASE,0x07); //start the timer 

alt_irq_register(TIMER_IRQ,(void*)TIMER_BASE,(void*)timer_ISR); 

 

 

//interrupt service routine 

 

 

void timer_ISR(void) 

{  

printf("\nthe data is %d \n" ,d); 

d++; 

IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE, 0x00); //clear the timeout bit 

}
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
225 Views

if i add these codes&#65306;IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_BASE,25000> >16); 

IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_BASE,25000 && 0xffff); 

the program won't work,why 

i have ready selected the"writable period"
0 Kudos
Altera_Forum
Honored Contributor II
225 Views

You probably meant '25000 & 0xffff' instead of '25000 && 0xffff' which will result in 25000 instead of 1.

0 Kudos
Altera_Forum
Honored Contributor II
225 Views

thanks very much,i'll try it,but i've already used that two statements many times before in my project,and there is nothing wrong.

0 Kudos
Reply