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

📄 motorpasso.lst

📁 Step motor functions for PIC microcontrollers written in C
💻 LST
📖 第 1 页 / 共 2 页
字号:
CCS PCH C Compiler, Version 3.242, 16465               24-abr-06 11:53

               Filename: C:\Documents and Settings\AndreDurao\Meus documentos\pic code\motorPasso.lst

               ROM used: 516 bytes (2%)
                         Largest free fragment is 32252
               RAM used: 6 (0%) at main() level
                         16 (1%) worst case
               Stack:    4 locations

*
0000:  GOTO   01AA
.................... #include "C:\Documents and Settings\AndreDurao\Meus documentos\pic code\motorPasso.h" 
.................... #include <18F452.h> 
.................... //////// Standard Header file for the PIC18F452 device //////////////// 
.................... #device PIC18F452 
.................... #list 
....................  
.................... #device adc=8 
....................  
.................... #FUSES NOWDT                 	//No Watch Dog Timer 
.................... #FUSES WDT128                	//Watch Dog Timer uses 1:128 Postscale 
.................... #FUSES XT                    	//Crystal osc <= 4mhz 
.................... #FUSES NOPROTECT             	//Code not protected from reading 
.................... #FUSES NOOSCSEN              	//Oscillator switching is disabled, main oscillator is source 
.................... #FUSES BROWNOUT              	//Reset when brownout detected 
.................... #FUSES BORV20                	//Brownout reset at 2.0V 
.................... #FUSES NOPUT                 	//No Power Up Timer 
.................... #FUSES STVREN                	//Stack full/underflow will cause reset 
.................... #FUSES NODEBUG               	//No Debug mode for ICD 
.................... #FUSES LVP                   	//Low Voltage Programming on B3(PIC16) or B5(PIC18) 
.................... #FUSES NOWRT                 	//Program memory not write protected 
.................... #FUSES NOWRTD                	//Data EEPROM not write protected 
.................... #FUSES NOWRTB                	//Boot block not write protected 
.................... #FUSES NOWRTC                	//configuration not registers write protected 
.................... #FUSES NOCPD                 	//No EE protection 
.................... #FUSES NOCPB                 	//No Boot Block code protection 
.................... #FUSES NOEBTR                	//Memory not protected from table reads 
.................... #FUSES NOEBTRB               	//Boot block not protected from table reads 
....................  
....................  
.................... #use delay(clock=20000000) 
0030:  CLRF   FEA
0032:  MOVLW  08
0034:  MOVWF  FE9
0036:  MOVF   FEF,W
0038:  BZ    0054
003A:  MOVLW  06
003C:  MOVWF  01
003E:  CLRF   00
0040:  DECFSZ 00,F
0042:  BRA    0040
0044:  DECFSZ 01,F
0046:  BRA    003E
0048:  MOVLW  7B
004A:  MOVWF  00
004C:  DECFSZ 00,F
004E:  BRA    004C
0050:  DECFSZ FEF,F
0052:  BRA    003A
0054:  RETLW  00
....................  
....................  
.................... #include <LCD.C> 
.................... /////////////////////////////////////////////////////////////////////////// 
.................... ////                             LCDD.C                                //// 
.................... ////                 Driver for common LCD modules                     //// 
.................... ////                                                                   //// 
.................... ////  lcd_init()   Must be called before any other function.           //// 
.................... ////                                                                   //// 
.................... ////  lcd_putc(c)  Will display c on the next position of the LCD.     //// 
.................... ////                     The following have special meaning:           //// 
.................... ////                      \f  Clear display                            //// 
.................... ////                      \n  Go to start of second line               //// 
.................... ////                      \b  Move back one position                   //// 
.................... ////                                                                   //// 
.................... ////  lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1)    //// 
.................... ////                                                                   //// 
.................... ////  lcd_getc(x,y)   Returns character at position x,y on LCD         //// 
.................... ////                                                                   //// 
.................... /////////////////////////////////////////////////////////////////////////// 
.................... ////        (C) Copyright 1996,2003 Custom Computer Services           //// 
.................... //// This source code may only be used by licensed users of the CCS C  //// 
.................... //// compiler.  This source code may only be distributed to other      //// 
.................... //// licensed users of the CCS C compiler.  No other use, reproduction //// 
.................... //// or distribution is permitted without written permission.          //// 
.................... //// Derivative programs created using this software in object code    //// 
.................... //// form are not restricted in any way.                               //// 
.................... /////////////////////////////////////////////////////////////////////////// 
....................  
.................... // As defined in the following structure the pin connection is as follows: 
.................... //     D0  enable 
.................... //     D1  rs 
.................... //     D2  rw 
.................... //     D4  D4 
.................... //     D5  D5 
.................... //     D6  D6 
.................... //     D7  D7 
.................... // 
.................... //   LCD pins D0-D3 are not used and PIC D3 is not used. 
....................  
.................... // Un-comment the following define to use port B 
.................... // #define use_portb_lcd TRUE 
....................  
....................  
.................... struct lcd_pin_map {                 // This structure is overlayed 
....................            BOOLEAN enable;           // on to an I/O port to gain 
....................            BOOLEAN rs;               // access to the LCD pins. 
....................            BOOLEAN rw;               // The bits are allocated from 
....................            BOOLEAN unused;           // low order up.  ENABLE will 
....................            int     data : 4;         // be pin B0. 
....................         } lcd; 
....................  
....................  
.................... #if defined(__PCH__) 
.................... #if defined use_portb_lcd 
....................    #byte lcd = 0xF81                   // This puts the entire structure 
.................... #else 
....................    #byte lcd = 0xF83                   // This puts the entire structure 
.................... #endif 
.................... #else 
.................... #if defined use_portb_lcd 
....................    #byte lcd = 6                  // on to port B (at address 6) 
.................... #else 
....................    #byte lcd = 8                 // on to port D (at address 8) 
.................... #endif 
.................... #endif 
....................  
.................... #if defined use_portb_lcd 
....................    #define set_tris_lcd(x) set_tris_b(x) 
.................... #else 
....................    #define set_tris_lcd(x) set_tris_d(x) 
.................... #endif 
....................  
....................  
.................... #define lcd_type 2           // 0=5x7, 1=5x10, 2=2 lines 
.................... #define lcd_line_two 0x40    // LCD RAM address for the second line 
....................  
....................  
.................... BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6}; 
....................                              // These bytes need to be sent to the LCD 
....................                              // to start it up. 
....................  
....................  
....................                              // The following are used for setting 
....................                              // the I/O port direction register. 
....................  
.................... struct lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out 
.................... struct lcd_pin_map const LCD_READ = {0,0,0,0,15}; // For read mode data pins are in 
....................  
....................  
....................  
.................... BYTE lcd_read_byte() { 
....................       BYTE low,high; 
....................       set_tris_lcd(LCD_READ); 
*
0074:  MOVLW  F0
0076:  MOVWF  F95
....................       lcd.rw = 1; 
0078:  BSF    F83.2
....................       delay_cycles(1); 
007A:  NOP   
....................       lcd.enable = 1; 
007C:  BSF    F83.0
....................       delay_cycles(1); 
007E:  NOP   
....................       high = lcd.data; 
0080:  SWAPF  F83,W
0082:  ANDLW  0F
0084:  MOVWF  0F
....................       lcd.enable = 0; 
0086:  BCF    F83.0
....................       delay_cycles(1); 
0088:  NOP   
....................       lcd.enable = 1; 
008A:  BSF    F83.0
....................       delay_us(1); 
008C:  NOP   
008E:  NOP   
0090:  NOP   
0092:  NOP   
0094:  NOP   
....................       low = lcd.data; 
0096:  SWAPF  F83,W
0098:  ANDLW  0F
009A:  MOVWF  0E
....................       lcd.enable = 0; 
009C:  BCF    F83.0
....................       set_tris_lcd(LCD_WRITE); 
009E:  MOVLW  00
00A0:  MOVWF  F95
....................       return( (high<<4) | low); 
00A2:  SWAPF  0F,W
00A4:  MOVWF  00
00A6:  MOVLW  F0
00A8:  ANDWF  00,F
00AA:  MOVF   00,W
00AC:  IORWF  0E,W
00AE:  MOVWF  01
.................... } 
00B0:  GOTO   00B8 (RETURN)
....................  
....................  
.................... void lcd_send_nibble( BYTE n ) { 
....................       lcd.data = n; 
*
0056:  SWAPF  0F,W
0058:  ANDLW  F0
005A:  MOVWF  00
005C:  MOVLW  0F
005E:  ANDWF  F83,W
0060:  IORWF  00,W
0062:  MOVWF  F83
....................       delay_cycles(1); 
0064:  NOP   
....................       lcd.enable = 1; 
0066:  BSF    F83.0
....................       delay_us(2); 
0068:  MOVLW  03
006A:  MOVWF  00
006C:  DECFSZ 00,F
006E:  BRA    006C
....................       lcd.enable = 0; 
0070:  BCF    F83.0
.................... } 
0072:  RETLW  00
....................  
....................  
.................... void lcd_send_byte( BYTE address, BYTE n ) { 
....................  
....................       lcd.rs = 0; 
*
00B4:  BCF    F83.1
....................       while ( bit_test(lcd_read_byte(),7) ) ; 
00B6:  BRA    0074
00B8:  MOVFF  01,0E
00BC:  BTFSC  01.7
00BE:  BRA    00B6
....................       lcd.rs = address; 
00C0:  BTFSS  0C.0
00C2:  BCF    F83.1
00C4:  BTFSC  0C.0

⌨️ 快捷键说明

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