⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dac_ctrl.rmh

📁 和picoblaze完全兼容的mcu ip core
💻 RMH
📖 第 1 页 / 共 3 页
字号:
/* Symbol Table */// BTN_east = CONSTANT: 2// BTN_north = CONSTANT: 1// BTN_south = CONSTANT: 4// BTN_west = CONSTANT: 8// ISR = LABEL: 192// LED0 = CONSTANT: 1// LED1 = CONSTANT: 2// LED2 = CONSTANT: 4// LED3 = CONSTANT: 8// LED4 = CONSTANT: 16// LED5 = CONSTANT: 32// LED6 = CONSTANT: 64// LED7 = CONSTANT: 128// LED_port = CONSTANT: 128// SPI_adc_conv = CONSTANT: 16// SPI_amp_cs = CONSTANT: 8// SPI_amp_sdi = CONSTANT: 64// SPI_amp_shdn = CONSTANT: 64// SPI_control_port = CONSTANT: 8// SPI_dac_clr = CONSTANT: 128// SPI_dac_cs = CONSTANT: 32// SPI_dac_tx_rx = LABEL: 122// SPI_init = LABEL: 119// SPI_input_port = CONSTANT: 1// SPI_output_port = CONSTANT: 4// SPI_rom_cs = CONSTANT: 2// SPI_sck = CONSTANT: 1// SPI_sdi = CONSTANT: 128// SPI_sdo = CONSTANT: 128// SPI_spare_control = CONSTANT: 4// calc_next_sine = LABEL: 94// chan_A_lsb = CONSTANT: 0// chan_A_msb = CONSTANT: 1// chan_B_lsb = CONSTANT: 2// chan_B_msb = CONSTANT: 3// chan_C_lsb = CONSTANT: 4// chan_C_msb = CONSTANT: 5// chan_D_lsb = CONSTANT: 6// chan_D_msb = CONSTANT: 7// cold_start = LABEL: 0// dac_reset = LABEL: 162// delay_1ms = LABEL: 177// delay_1s = LABEL: 187// delay_1us = LABEL: 168// delay_1us_constant = CONSTANT: 11// delay_20ms = LABEL: 182// delay_40us = LABEL: 172// init_sine_wave = LABEL: 82// mult_loop = LABEL: 103// next_SPI_dac_bit = LABEL: 123// no_mult_add = LABEL: 110// s0 = REGISTER: 0// s1 = REGISTER: 1// s2 = REGISTER: 2// s3 = REGISTER: 3// s4 = REGISTER: 4// s5 = REGISTER: 5// s6 = REGISTER: 6// s7 = REGISTER: 7// s8 = REGISTER: 8// s9 = REGISTER: 9// sA = REGISTER: 10// sB = REGISTER: 11// sC = REGISTER: 12// sD = REGISTER: 13// sE = REGISTER: 14// sF = REGISTER: 15// sample_count_lsb = CONSTANT: 32// sample_count_msb = CONSTANT: 33// set_dac = LABEL: 134// sine_k_lsb = CONSTANT: 20// sine_k_msb = CONSTANT: 21// sine_y1_lsb = CONSTANT: 18// sine_y1_msb = CONSTANT: 19// sine_y_lsb = CONSTANT: 16// sine_y_msb = CONSTANT: 17// slope_down = LABEL: 42// square_count = CONSTANT: 9// square_high = LABEL: 58// store_channel_B = LABEL: 50// store_channel_C = LABEL: 60// switch0 = CONSTANT: 16// switch1 = CONSTANT: 32// switch2 = CONSTANT: 64// switch3 = CONSTANT: 128// switch_port = CONSTANT: 0// triangle_up_down = CONSTANT: 8// wait_1ms = LABEL: 178// wait_1s = LABEL: 188// wait_1us = LABEL: 169// wait_20ms = LABEL: 183// wait_40us = LABEL: 173// wait_int = LABEL: 16// warm_start = LABEL: 15/* Program Code */// #1: ;KCPSM3 Program - SPI Control of D/A converter on Spartan-3E Starter Kit.// #2: ;// #3: ;// #4: ;Ken Chapman - Xilinx Ltd// #5: ;// #6: ;Version v1.00 - 24th November 2005// #7: ;// #8: ;This program uses an 8KHz interrupt to generate test waveforms on the// #9: ;4 analogue outputs provided by the Linear Technology LTC2624 device.// #10: ;// #11: ;As well as the port connections vital to communication with the UART and the SPI// #12: ;FLASH memory, there are additional port connections used to disable the other// #13: ;devices sharing the SPI bus on the Starter Kit board. Although these could have been// #14: ;controlled at the hardware level, they are included in this code to aid// #15: ;future investigations of communication with the other SPI devices using PicoBlaze.// #16: ;// #17: ;Connections to the LEDs, switches and press buttons are provided to aid// #18: ;development and enable further experiments. Otherwise know as having fun!// #19: ;// #20: ;Port definitions// #21: ;// #22: ;// #23: CONSTANT(SPI_control_port,8) ;SPI clock and chip selects// #24: CONSTANT(SPI_sck,1) ;                  SCK - bit0// #25: CONSTANT(SPI_rom_cs,2) ;    serial rom select - bit1// #26: CONSTANT(SPI_spare_control,4) ;                spare - bit2// #27: CONSTANT(SPI_amp_cs,8) ;     amplifier select - bit3// #28: CONSTANT(SPI_adc_conv,16) ;          A/D convert - bit4// #29: CONSTANT(SPI_dac_cs,32) ;           D/A select - bit5// #30: CONSTANT(SPI_amp_shdn,64) ;       amplifier SHDN - bit6// #31: CONSTANT(SPI_dac_clr,128) ;            D/A clear - bit7// #32: ;// #33: CONSTANT(SPI_output_port,4) ;SPI data output// #34: CONSTANT(SPI_sdo,128) ;   SDO - bit7// #35: ;// #36: CONSTANT(SPI_input_port,1) ;SPI data input// #37: CONSTANT(SPI_sdi,128) ;             SDI - bit7// #38: CONSTANT(SPI_amp_sdi,64) ;   amplifier SDI - bit6// #39: ;// #40: ;// #41: CONSTANT(LED_port,128) ;8 simple LEDs// #42: CONSTANT(LED0,1) ;     LED 0 - bit0// #43: CONSTANT(LED1,2) ;         1 - bit1// #44: CONSTANT(LED2,4) ;         2 - bit2// #45: CONSTANT(LED3,8) ;         3 - bit3// #46: CONSTANT(LED4,16) ;         4 - bit4// #47: CONSTANT(LED5,32) ;         5 - bit5// #48: CONSTANT(LED6,64) ;         6 - bit6// #49: CONSTANT(LED7,128) ;         7 - bit7// #50: ;// #51: ;// #52: CONSTANT(switch_port,0) ;Read switches and press buttons// #53: CONSTANT(BTN_north,1) ;  Buttons     North - bit0// #54: CONSTANT(BTN_east,2) ;               East - bit1// #55: CONSTANT(BTN_south,4) ;              South - bit2// #56: CONSTANT(BTN_west,8) ;               West - bit3// #57: CONSTANT(switch0,16) ;  Switches        0 - bit4// #58: CONSTANT(switch1,32) ;                  1 - bit5// #59: CONSTANT(switch2,64) ;                  2 - bit6// #60: CONSTANT(switch3,128) ;                  3 - bit7// #61: ;// #62: ;// #63: ;// #64: ;// #65: ;Special Register usage// #66: ;// #67: ;// #68: ;Useful data constants// #69: ;// #70: ;// #71: ;Constant to define a software delay of 1us. This must be adjusted to reflect the// #72: ;clock applied to KCPSM3. Every instruction executes in 2 clock cycles making the// #73: ;calculation highly predictable. The '6' in the following equation even allows for// #74: ;'CALL delay_1us' instruction in the initiating code.// #75: ;// #76: ; delay_1us_constant =  (clock_rate - 6)/4       Where 'clock_rate' is in MHz// #77: ;// #78: ;Example: For a 50MHz clock the constant value is (10-6)/4 = 11  (0B Hex).// #79: ;For clock rates below 10MHz the value of 1 must be used and the operation will// #80: ;become lower than intended.// #81: ;// #82: CONSTANT(delay_1us_constant,11)// #83: ;// #84: ;// #85: ;// #86: ;// #87: ;// #88: ;// #89: ;Scratch Pad Memory Locations// #90: ;// #91: ;Values to be written to the D/A converter// #92: ;// #93: ;// #94: CONSTANT(chan_A_lsb,0) ;Channel A value LS-Byte// #95: CONSTANT(chan_A_msb,1) ;                MS-Byte// #96: ;// #97: CONSTANT(chan_B_lsb,2) ;Channel B value LS-Byte// #98: CONSTANT(chan_B_msb,3) ;                MS-Byte// #99: ;// #100: CONSTANT(chan_C_lsb,4) ;Channel C value LS-Byte// #101: CONSTANT(chan_C_msb,5) ;                MS-Byte// #102: ;// #103: CONSTANT(chan_D_lsb,6) ;Channel D value LS-Byte// #104: CONSTANT(chan_D_msb,7) ;                MS-Byte// #105: ;// #106: ;// #107: ;Value used to synthesise a triangle wave// #108: ;// #109: CONSTANT(triangle_up_down,8) ;Determines up or down slope// #110: ;// #111: ;Value used to synthesise a square wave// #112: ;// #113: CONSTANT(square_count,9) ;Counts samples in square wave// #114: ;// #115: ;// #116: ;Values used to synthesise a sine wave// #117: ;// #118: CONSTANT(sine_y_lsb,16) ;Sine wave value LS-Byte// #119: CONSTANT(sine_y_msb,17) ;                 MS-Byte// #120: CONSTANT(sine_y1_lsb,18) ;Sine wave delayed LS-Byte// #121: CONSTANT(sine_y1_msb,19) ;                  MS-Byte// #122: CONSTANT(sine_k_lsb,20) ;Sine constant LS-Byte// #123: CONSTANT(sine_k_msb,21) ;              MS-Byte// #124: ;// #125: ;// #126: ;Sample counter used to give activity indication on LEDs// #127: ;// #128: CONSTANT(sample_count_lsb,32) ;16-bit counter LS-Byte// #129: CONSTANT(sample_count_msb,33) ;               MS-Byte// #130: ;// #131: ;Initialise the system// #132: ;// #133: ;// @000 #134: [cold_start]30077 // @000 #134: CALL(SPI_init) ;initialise SPI bus ports30052 // @001 #135: CALL(init_sine_wave) ;initialise sine wave synthesis values300bb // @002 #136: CALL(delay_1s) ;bus settling delay00000 // @003 #137: LOAD(s0,0) ;clear all internal D/A values2e000 // @004 #138: STORE(s0,chan_A_lsb)2e001 // @005 #139: STORE(s0,chan_A_msb)2e002 // @006 #140: STORE(s0,chan_B_lsb)2e003 // @007 #141: STORE(s0,chan_B_msb)2e004 // @008 #142: STORE(s0,chan_C_lsb)2e005 // @009 #143: STORE(s0,chan_C_msb)2e006 // @00a #144: STORE(s0,chan_D_lsb)2e007 // @00b #145: STORE(s0,chan_D_msb)2e008 // @00c #146: STORE(s0,triangle_up_down) ;initial slope is up300a2 // @00d #147: CALL(dac_reset) ;reset D/A converter on all channels3c001 // @00e #148: ENABLE(INTERRUPT) ;Interrupts define 8KHz sample rate// #149: ;// #150: ;// #151: ;The program is interrupt driven to maintain an 8KHz sample rate. The main body// #152: ;of the program waits for an interrupt to occur. The interrupt updates all four// #153: ;analogue outputs with values stored in scratch pad memory. This takes approximately// #154: ;58us of the 125us available between interrupts. The main program then prepares// #155: ;new values for the analogue outputs (in less than 67us) before waiting for the// #156: ;next interrupt.// #157: ;// #158: ;// @00f #159: [warm_start]00fff // @00f #159: LOAD(sF,FF) ;flag set and wait for interrupt to be serviced// @010 #160: [wait_int]14fff // @010 #160: COMPARE(sF,FF)35010 // @011 #161: JUMP(Z,wait_int) ;interrupt clears the flag// #162: ;// #163: ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -