当前位置:首页 >> 信息与通信 >>

Altium教程Memec Virtex4 LX25 LC软件设计C1


Memec Virtex4 LX25 LC - TSK3000 软件设计

第一部分 1.1

原理图

FPGA_Memec_Virtex4_LX25_LC_Rev1_Board.SchDoc

The project for Memec Virtex-4 LX25 LC Rev.1 Board f

itted with XC4VLX25-10SF363C device

LCD_E LCD_RS LCD_DB[7..0]

O7 O6 O5 O4 O3 O2 O1 O0

U_IO1 Port Wishbone I[7..0] PAO[7..0] PAI[7..0] PBO[7..0] PBI[7..0] PCO[7..0] PCI[7..0] I[7..0] PDO[7..0] PDI[7..0] WB_PRTIO STB_I CYC_I ACK_O ADR_I[1..0] DAT_O[7..0] DAT_I[7..0] WE_I CLK_I RST_I

U_WB_INTERCON_PERI1 Wishbone Interconnect s0_STB_O s0_CYC_O s0_ACK_I s0_ADR_O[1..0] s0_DAT_I[7..0] s0_DAT_O[7..0] s0_SEL_O[3..0] s0_WE_O s0_CLK_O s0_RST_O WB_INTERCON m0_STB_I m0_CYC_I m0_ACK_O m0_ADR_I[23..0] m0_DAT_O[31..0] m0_DAT_I[31..0] m0_SEL_I[3..0] m0_WE_I m0_CLK_I m0_RST_I m0_INT_O[31..0]

P1 TSK3000A 32-Bit RISC Processor IO_STB_O IO_CYC_O IO_ACK_I IO_ADR_O[23..0] IO_DAT_I[31..0] IO_DAT_O[31..0] IO_SEL_O[3..0] IO_WE_O IO_CLK_O IO_RST_O INT_I[31..0] ME_STB_O ME_CYC_O ME_ACK_I ME_ADR_O[31..0] ME_DAT_I[31..0] ME_DAT_O[31..0] ME_SEL_O[3..0] ME_WE_O ME_CLK_O ME_RST_O

GND GND

DIP0 - blink the LEDs DIP1 - shift to the right DIP2 - shift to the left

GND DIP[7..0] LEDS[3..0] OA[3..0] OB[3..0]

[7..0]

Current Configuration
MDU : Installed Debug Hardware : Installed Internal Memory : 8 KB

U5

U4 /4 I BUFG U6 O TSK3000A CLK_I RST_I

40MHz Clock Reset

CLK_100

CDIV4DC50 PUSH0 INV

This Project includes the Memec Virtex-4 LX25 LC Board Clock, DIP Switches, LCD Display, Leds and Push Buttons. JTAG_NEXUS_TDI JTAG_NEXUS_TDO JTAG_NEXUS_TCK JTAG_NEXUS_TMS VCC TDI TDO TCK TMS TRST
JTAG JTAG JTAG JTAG JTAG
. . .

The TSK3000 soft processor is scanning the switches and is refreshing the Leds at regular intervals. The value outputted to the Leds will be reversed when turning on DIP0, shifted to the right when turning on DIP1 and shifted to the left when turning on DIP2. Pressing PUSH0 will reset the MCU - refreshing the LCD Display with the initial message and the Leds with a default value.

JTAG

第1页

共 16 页

1.2

hardware.h

//.............................................................................. // Automatically generated header file. // Generated: 1:51:17 PM 30/03/2005 // This file should not be edited. //..............................................................................

#ifndef __HARDWARE_H__ #define __HARDWARE_H__

//.............................................................................. #define Base_IO #define Size_IO 0xFF100000 0x00000004

//..............................................................................

//.............................................................................. #define Base_P1 #define Size_P1 0x00000000 0x00001000

//..............................................................................

//.............................................................................. #define Base_P1_RAM #define Size_P1_RAM 0x00001000 0x00001000

//..............................................................................

#endif // __HARDWARE_H__

第2页

共 16 页

1.3
|*

MsgPatterns.h

/*****************************************************************************\

|* COPYRIGHT: |* |* DESCRIPTION: |*

Copyright (c) 2004, PurPer

Patterns

\*****************************************************************************/

extern unsigned char Patterns[64];

第3页

共 16 页

1.4
|*

LcdControl.h

/*****************************************************************************\

|* COPYRIGHT: |* |* DESCRIPTION: |*

Copyright (c) 2004, PurPer

Simple routines to drive the LCD

\*****************************************************************************/

void inline Write_LCD void void void void void void Write_DR_LCD InitLCD LCD_WriteString LCD_ClearDisplay LCD_Set_IconPattern LCD_GotoXY

(unsigned char Data); (unsigned char Data); (void); (const char *str); (void); (int Icon, int Pattern); (unsigned char X, unsigned char Y);

void void

Wait_100us Wait_1ms

(int Time); (int Time);

第4页

共 16 页

1.5
|*

main.c

/*****************************************************************************\

|* COPYRIGHT: |* |* DESCRIPTION: |*

Copyright (c) 2004, PurPer

Simple LCD example using the TSK3000A soft processor

\*****************************************************************************/

#include "hardware.h" #include "LcdControl.h" #include "MsgPatterns.h"

#define IO_BASE(base) ((volatile unsigned char *) base) #define IO_DIPS(base) #define IO_LEDS(base) IO_BASE(base)[2] IO_BASE(base)[3]

#define SW

IO_DIPS(Base_IO)

#define LEDS IO_LEDS(Base_IO)

typedef enum { blink, shift_right, shift_left } mode;

void main (void) { unsigned char leds;

第5页

共 16 页

InitLCD();

LCD_ClearDisplay();

LCD_Set_IconPattern(0, 0); LCD_Set_IconPattern(1, 1); LCD_Set_IconPattern(2, 2); LCD_Set_IconPattern(3, 3); LCD_Set_IconPattern(4, 4); LCD_Set_IconPattern(5, 5); LCD_Set_IconPattern(6, 6); LCD_Set_IconPattern(7, 7);

LCD_GotoXY(0, 0); Write_DR_LCD(0); Write_DR_LCD(1); Write_DR_LCD(2); Write_DR_LCD(3); LCD_WriteString(" Live Design"); LCD_GotoXY(0, 1); Write_DR_LCD(4); Write_DR_LCD(5); Write_DR_LCD(6); Write_DR_LCD(7); LCD_WriteString(" enabled ");

leds = blink; while (1) { switch ( SW ) {

第6页

共 16 页

case 0x01 : leds = blink

; break;

case 0x02 : leds = shift_right ; break; case 0x04 : leds = shift_left } Wait_1ms(20); ; break;

switch ( leds ) { case blink : if ( (LEDS != 0x00) & (LEDS != 0x0F) ) LEDS = 0x0F; else LEDS =~ LEDS; break; case shift_right : if ( (LEDS == 0x00) | (LEDS == 0x0F) ) LEDS = 0x08; else LEDS >>= 1; break; case shift_left : if ( (LEDS == 0x00) | (LEDS == 0x0F) ) LEDS = 0x01; else LEDS <<= 1; break; } Wait_1ms(100); }

}

第7页

共 16 页

1.6
|*

MsgPatterns.c

/*****************************************************************************\

|* COPYRIGHT: |* |* DESCRIPTION: |*

Copyright (c) 2004, PurPer

Patterns

\*****************************************************************************/

#define HEX__(n) 0x##n##LU /* 8-bit conversion function */ #define B8__(x) ((x&0x0000000FLU)?1:0) \ +((x&0x000000F0LU)?2:0) \ +((x&0x00000F00LU)?4:0) \ +((x&0x0000F000LU)?8:0) \ +((x&0x000F0000LU)?16:0) \ +((x&0x00F00000LU)?32:0) \ +((x&0x0F000000LU)?64:0) \ +((x&0xF0000000LU)?128:0) /* *** user macros *** */ /* for upto 8-bit binary constants */ #define B8(d) ((unsigned char)B8__(HEX__(d)))

unsigned char Patterns[64] = {

//0.

Live Design Logo B8(00000000), B8(00000000), B8(00000000), B8(00000001),

第8页

共 16 页

B8(00000011), B8(00000110), B8(00001100), B8(00001100), //1. B8(00000000), B8(00000011), B8(00011110), B8(00010000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), //2. B8(00000001), B8(00011000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), //3. B8(00010000), B8(00001100), B8(00000110), B8(00000010), B8(00000011), B8(00000011), B8(00000011), B8(00000011),

第9页

共 16 页

//4. B8(00001100), B8(00011000), B8(00001000), B8(00001000), B8(00001100), B8(00000100), B8(00000010), B8(00000001), //5. B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000011), //6. B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000000), B8(00000001), B8(00001111), //7. B8(00000011), B8(00000011), B8(00000111),

第 10 页

共 16 页

B8(00000110), B8(00001100), B8(00011000), B8(00010000), B8(00000000) };

第 11 页

共 16 页

1.7
|*

LcdControl.c

/*****************************************************************************\

|* COPYRIGHT: |* |* DESCRIPTION: |*

Copyright (c) 2004, PurPer

Simple routines to drive the LCD

\*****************************************************************************/

#include "hardware.h" #include "MsgPatterns.h"

#define US_COUNT

497

#define ONE_MS_COUNT 10

#define IO_BASE(base) ((volatile unsigned char *) base) #define IO_LCD_CTRL(base) IO_BASE(base)[0] #define IO_LCD_DATA(base) IO_BASE(base)[1]

#define IO_LCD_RS_HIGH(base) (IO_LCD_CTRL(base) = (IO_LCD_CTRL(base) | 0x01)) #define IO_LCD_RS_LOW(base) (IO_LCD_CTRL(base) = (IO_LCD_CTRL(base) & 0xFE)) #define IO_LCD_E_HIGH(base) (IO_LCD_CTRL(base) = (IO_LCD_CTRL(base) | 0x02)) #define IO_LCD_E_LOW(base) (IO_LCD_CTRL(base) = (IO_LCD_CTRL(base) & 0xFD))

#define IO_LCD_T_HIGH(base) (IO_LCD_CTRL(base) = (IO_LCD_CTRL(base) | 0x80)) #define IO_LCD_T_LOW(base) (IO_LCD_CTRL(base) = (IO_LCD_CTRL(base) & 0x7F))

#define LCD_Putch(ch) Write_DR_LCD(ch) #define LCD_Set_CGRAM_Address(Address) Wait_1ms(3); Write_IR_LCD((Address & 0x3F) | 0x40) #define LCD_Set_DDRAM_Address(Address) Wait_1ms(3); Write_IR_LCD(Address | 0x80)

void Wait_100us(int Time)

第 12 页

共 16 页

{ int i, j; for (j = Time; j > 0; j--) { for (i = US_COUNT; i > 0; i--) { __asm("nop"); } } }

void Wait_1ms(int Time) { int i; for (i = Time; i > 0; i--) { Wait_100us(ONE_MS_COUNT); } }

void inline Write_LCD(unsigned char Data) { IO_LCD_DATA(Base_IO) = Data; IO_LCD_E_HIGH(Base_IO); Wait_100us(1); IO_LCD_E_LOW(Base_IO); }

void inline Write_IR_LCD(unsigned char Data) { IO_LCD_RS_LOW(Base_IO);

第 13 页

共 16 页

Wait_100us(1); Write_LCD(Data); }

void Write_DR_LCD(unsigned char Data) { IO_LCD_RS_HIGH(Base_IO); Wait_1ms(2); Write_LCD(Data); }

void InitLCD(void) { IO_LCD_E_LOW(Base_IO); IO_LCD_RS_LOW(Base_IO); IO_LCD_DATA(Base_IO) = 0x00;

Wait_1ms(40); Write_IR_LCD(0x38); Wait_1ms(8); Write_IR_LCD(0x38); Wait_100us(1); Write_IR_LCD(0x38); Wait_1ms(1); Write_IR_LCD(0x01); Wait_1ms(3); Write_IR_LCD(0x0E); Wait_1ms(3); Write_IR_LCD(0x06); Wait_1ms(3); }

// wait for more than 15ms after powerup

// wait for another 8 ms

// Wait more than 100us // Function Set, 8-bit, 2 line

//Clear Display;

// Display on, Cursor On

//Increment address counter and move cursor by 1

第 14 页

共 16 页

void LCD_GotoXY(unsigned char X, unsigned char Y) { Wait_1ms(2); Write_IR_LCD(0x80 | (X + 0x40* Y)); }

void LCD_WriteString(const char * str) { while (* str) { LCD_Putch(* str++); } }

void LCD_ClearDisplay(void) { Wait_1ms(3); Write_IR_LCD(0x01); }

/*The following routine sets one of 8 available Icons (contained in CGRAM) to a pattern defined by Patterns[][] */ void LCD_Set_IconPattern(int Icon, int Pattern) { int idx = Pattern << 3; LCD_Set_CGRAM_Address(Icon << 3); for (int i = 0; i < 8; i++) { Write_DR_LCD(Patterns[idx++]); } }

第 15 页

共 16 页

第 16 页

共 16 页


相关文章:
更多相关标签: