Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Error (10170), Urgent!!! help me find out what's the error with this program,Thanks!!

im using quartus II 9.1

Error (10170): Verilog HDL syntax error at <location> near text "#"; expecting a description

# include <stdio.h># include <unistd.h># include "system.h"# include "alt_types.h"# include "altera_avalon_timer_regs.h"# include "altera_avalon_pio_regs.h"# include "altera_avalon_lcd_16207_regs.h"# define LCD_WR_COMMAND_REG 0# define LCD_RD_STATUS_REG 1# define LCD_WR_DATA_REG 2# define LCD_RD_DATA_REG 3

void lcd_init( void) {

usleep(15000); /* Wait for more than 15 ms before init */

/* Set function code four times -- 8-bit, 2 line, 5x7 mode */

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x38);

usleep(4100); /* Wait for more than 4.1 ms */

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x38);

usleep(100); /* Wait for more than 100 us */

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x38);

usleep(5000); /* Wait for more than 100 us */

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x38);

usleep(100); /* Wait for more than 100 us */

/* Set Display to OFF*/

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x08);

usleep(100);

/* Set Display to ON */

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x0C);

usleep(100);

/* Set Entry Mode -- Cursor increment, display doesn't shift */

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x06);

usleep(100);

/* Set the Cursor to the home position */

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x02);

usleep(2000);

/* Display clear */

IOWR(LCD_0_BASE, LCD_WR_COMMAND_REG, 0x01);

usleep(2000);

}

alt_u32 test_lcd( void) {

int i;

char message[17] = "Hello World... ";

char done[15] = "Done! ";

/* Write a simple message on the first line. */

for(i = 0; i < 16; i++) {

IOWR(LCD_0_BASE, LCD_WR_DATA_REG,message);

usleep(100);

}

/* count along the bottom row */

/* set address */

iowr(lcd_0_base, lcd_wr_command_reg,0xc0);

usleep(1000);

/* display count */

for (i = 0; i < 10; i++) {

iowr(lcd_0_base, lcd_wr_data_reg, (char)(i+0x30) );

usleep(500000); /* wait 0.5 sec */

}

/* write "done!" message on first line. */

/* set address */

iowr(lcd_0_base, lcd_wr_command_reg,0x80);

usleep(1000);

/* write data */

for(i = 0; i < 14; i++) {

iowr(lcd_0_base, lcd_wr_data_reg, done);

usleep(100);

}

return(0);

}

alt_u32 wait_onesec( void) {

IOWR_ALTERA_AVALON_TIMER_PERIODL( TIMER_0_BASE,(48000000 & 0xFFFF));

IOWR_ALTERA_AVALON_TIMER_PERIODH( TIMER_0_BASE,((48000000>>16) & 0xFFFF));

IOWR_ALTERA_AVALON_TIMER_STATUS ( TIMER_0_BASE, 0);

IOWR_ALTERA_AVALON_TIMER_CONTROL ( TIMER_0_BASE, 0x4);

while((IORD_ALTERA_AVALON_TIMER_STATUS(TIMER_0_BASE) &

ALTERA_AVALON_TIMER_STATUS_TO_MSK) == 0) {}

return(0);

}

int main( void) {

int count;

lcd_init();

test_lcd();

count = 0;

while (1) {

count = count & 0xff;

IOWR_ALTERA_AVALON_PIO_DATA( RED_LEDS_BASE, count);

wait_onesec();

IOWR_ALTERA_AVALON_PIO_DATA( RED_LEDS_BASE, count++);

}

return (0);

}

1 Reply