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++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

problem when i debug CF card

Altera_Forum
Honored Contributor II
1,122 Views

nios2-terminal: There are no JTAG UARTs available which match the --device and 

nios2-terminal: --instance options you provided. 

 

what is the problem?how to solve it? thx v much 

 

my software : 

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

//#include "altera_avalon_pio_regs.h"# include "altera_avalon_cf_regs.h"# include "altera_avalon_cf.h" 

alt_u8 data[512]; 

alt_u8 flag1,flag2; 

 

//parameter setting 

//lba2:sector number,lba3:adr0-7,lba4:adr8-15,lba5:adr16-23 

//lba6:set lba addressing & lba:adr24-27 

void busy_check(void) 

{alt_u8 temp; 

temp=IORD_ALTERA_AVALON_CF_IDE_STATUS(CF_0_IDE_BASE); 

while(temp&0x50!=0x50) 

void set_para(alt_u8 comm,alt_u8 lba2,alt_u8 lba3,alt_u8 lba4,alt_u8 lba5,alt_u8 lba6)  

 

{//set sector number 

busy_check(); 

IOWR_ALTERA_AVALON_CF_IDE_SECTOR_COUNT(CF_0_IDE_BASE, 1); 

//set lba3:adr0-7 

busy_check(); 

IOWR_ALTERA_AVALON_CF_IDE_SECTOR_NUMBER(CF_0_IDE_BASE, lba3);  

//set lba4:adr8-15 

busy_check(); 

IOWR_ALTERA_AVALON_CF_IDE_CYLINDER_LOW(CF_0_IDE_BASE, lba4); 

//set lba5:adr16-23 

busy_check(); 

IOWR_ALTERA_AVALON_CF_IDE_CYLINDER_HIGH(CF_0_IDE_BASE, lba5); 

//set cf card as LBA ADDRESSING&lba:adr24-27  

busy_check(); 

IOWR_ALTERA_AVALON_CF_IDE_DEVICE_HEAD(CF_0_IDE_BASE, lba6); 

// write commond 0x30 to cf card 

busy_check(); 

IOWR_ALTERA_AVALON_CF_IDE_COMMAND(CF_0_IDE_BASE, comm); 

//write data to cf card 

void wr_data(void) 

{alt_u16 i,ptr; 

alt_u8 temp; 

for(i=0;i<512;i++) 

data[i]=i; 

 

for(ptr=0;ptr<512;ptr++) 

{busy_check(); 

IOWR_ALTERA_AVALON_CF_IDE_DATA(CF_0_IDE_BASE, data[ptr]);  

}  

//read data from cf card 

void rd_data(void) 

{alt_u16 i,ptr; 

alt_u8 temp; 

for(ptr=0;ptr<512;ptr++) 

{ busy_check(); 

temp=IORD_ALTERA_AVALON_CF_IDE_DATA(CF_0_IDE_BASE); 

printf("*****%c*****",temp); 

}  

 

 

int main(void) 

alt_u8 present; 

//-------------------------------------------------------------- 

//Copact FLash presence checking 

//-------------------------------------------------------------- 

//alt_avalon_ide_cf_init(CF_0_CTL_BASE ); 

present=IORD_ALTERA_AVALON_CF_IDE_STATUS(CF_0_IDE_BASE); 

if(present != 0) 

printf("Waiting for the Compact Flash Card to be inserted ......\n"); 

/* 

while(present != 0) 

present =IORD_ALTERA_AVALON_CF_IDE_STATUS(CF_0_IDE_BASE); 

printf(""); 

 

printf("\nCompact Flash is detected ......\n"); 

*/ 

//Power the device 

IOWR_ALTERA_AVALON_CF_IDE_CTL(CF_0_CTL_BASE, 0x2) ; 

 

 

//write a 512bytes to a sector of the cf card 

set_para(0x30,1,1,0,0,0xe0); 

wr_data(); 

set_para(0x20,1,1,0,0,0xe0); 

rd_data(); 

 

IOWR_ALTERA_AVALON_CF_IDE_CTL(CF_0_CTL_BASE, 0x0) ; 

printf(" \n\n --------------------------------------------\n"); 

printf(" Now it&#39;s safe to remove the CompactFlash Card\n"); 

printf(" --------------------------------------------\n\n"); 

 

 

return (0); 

}
0 Kudos
0 Replies
Reply