📄 4_20ma_main.lst
字号:
021C: GOTO 0218
.................... while( input(slave_I2C_clk) ); //等待slave_I2C_clk变为0;
0220: BSF F93.2
0222: BTFSC F81.2
0224: GOTO 0220
.................... //上面两句是等待一个移位时钟到到来
.................... bit_set(*0xF93,1); //端口B的方向寄存器地址为0xF93,将RB1设置为输入
0228: BSF F93.1
.................... bit_set(*0xF93,2); //端口B的方向寄存器地址为0xF93,将RB2设置为输入
022A: BSF F93.2
.................... }
022C: RETLW 00
....................
....................
....................
....................
.................... /*
.................... #INT_EXT1
.................... void ext_int1_service()
.................... {
.................... BYTE j,SLAVE_address;
.................... int1 receive_ok;
.................... char receive_temp[5]; //用来存放接收到的数据,以ASCII格式存放
.................... if( input(slave_I2C_clk)) //若slave_I2C_clk=1时,在slave_I2C_data脚出现下降沿,表示I2C起动条件满足,则执行下面语句
.................... {disable_interrupts(INT_EXT1);//不使能外部中断1
.................... if( wait_I2C_clk_low() ) //等待slave_I2C_clk变为0
.................... {
.................... if( wait_I2C_clk_high() ) //等待slave_I2C_clk变高;若slave_I2C_clk=1,表示开始有数据移进来
.................... {SLAVE_address=read_IIC_byte(); //读到一个字节;
.................... if(SLAVE_address==0xaa) //若地址相符合,则执行下面语句
.................... {
.................... if( wait_I2C_clk_low() ) //等待slave_I2C_clk变为0
.................... {output_low(slave_I2C_data);//在slave_I2C_clk变为0时,本从机发送应答ACK;
.................... if( wait_I2C_clk_high() ) //等待主机将应答ACK信号取走
.................... {if( wait_I2C_clk_low() ) //等待slave_I2C_clk变为0
.................... {
.................... if( wait_I2C_clk_high() ) //等待slave_I2C_clk变高;若slave_I2C_clk=1,表示开始有数据移进来
.................... {for(j=0;j<=4;j++)
.................... {receive_temp[j]=read_IIC_byte();//读到一个字节;
.................... if(receive_temp[j]!=0) receive_ok=1;
.................... else{
.................... receive_ok=0;
.................... break;
.................... }
.................... }
.................... if(receive_ok)
.................... {strcpy( receive_string_buffer,receive_temp );//将receive_temp所指内容拷贝到receive_string_buffer中;
.................... write_string_to_DAC7612U(receive_string_buffer,14); //将接收到的5位ASCII码写入DAC7612U
.................... lcd1604_display(receive_string_buffer); //将接收到的5位ASCII码写入LCD显示;
.................... }
.................... }
.................... }
.................... }
.................... }
.................... }
.................... }
.................... }
.................... enable_interrupts(INT_EXT1);//使能外部中断1
.................... bit_set(*0xF93,1); //端口B的方向寄存器地址为0xF93,将RB1设置为输入
.................... bit_set(*0xF93,2); //端口B的方向寄存器地址为0xF93,将RB2设置为输入
.................... }
.................... }
.................... */
....................
....................
.................... #include "C:\A\DAC7612U.C "
.................... #ifndef DAC7612U_CS
.................... #define DAC7612U_SCLK PIN_A3
.................... #define DAC7612U_SDATA PIN_F0
.................... #define DAC7612U_LOAD PIN_A2
.................... #else
.................... #define DAC7612U_SCLK PIN_A3
.................... #define DAC7612U_SDATA PIN_F0
.................... #define DAC7612U_LOAD PIN_A2
.................... //#define DAC7612U_CS PIN_A2 //该脚不使用,在电路中,已经接地
.................... #endif
....................
.................... #include<stdlib.h>
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (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. ////
.................... ///////////////////////////////////////////////////////////////////////////
....................
.................... #ifndef _STDLIB
.................... #define _STDLIB
....................
.................... //---------------------------------------------------------------------------
.................... // Definitions and types
.................... //---------------------------------------------------------------------------
....................
.................... #ifndef RAND_MAX
.................... #define RAND_MAX 32767 // The value of which is the maximum value
.................... // ... returned by the rand function
.................... #endif
....................
.................... typedef struct {
.................... signed int quot;
.................... signed int rem;
.................... } div_t;
....................
.................... typedef struct {
.................... signed long quot;
.................... signed long rem;
.................... } ldiv_t;
....................
.................... #include <stddef.h>
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (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. ////
.................... ///////////////////////////////////////////////////////////////////////////
....................
.................... #ifndef _STDDEF
....................
.................... #define _STDDEF
....................
.................... #if sizeof(int *)==1
.................... #define ptrdiff_t int
.................... #else
.................... #define ptrdiff_t long
.................... #endif
....................
.................... #define size_t int
.................... #define wchar_t char
.................... #define NULL 0
....................
.................... #define offsetof(s,f) (offsetofbit(s,f)/8)
....................
.................... #endif
....................
....................
.................... //---------------------------------------------------------------------------
.................... // String conversion functions
.................... //---------------------------------------------------------------------------
....................
.................... /* Standard template: float atof(char * s)
.................... * converts the initial portion of the string s to a float.
.................... * returns the converted value if any, 0 otherwise
.................... */
.................... float atof(char * s);
....................
.................... /* Standard template: signed int atoi(char * s)
.................... * converts the initial portion of the string s to a signed int
.................... * returns the converted value if any, 0 otherwise
.................... */
.................... signed int atoi(char *s);
....................
.................... /* Syntax: signed int32 atoi32(char * s)
.................... converts the initial portion of the string s to a signed int32
.................... returns the converted value if any, 0 otherwise*/
.................... signed int32 atoi32(char *s);
....................
.................... /* Standard template: signed long atol(char * s)
.................... * converts the initial portion of the string s to a signed long
.................... * returns the converted value if any, 0 otherwise
.................... */
.................... signed long atol(char *s);
....................
.................... /* Standard template: float strtol(char * s,char *endptr)
.................... * converts the initial portion of the string s to a float
.................... * returns the converted value if any, 0 otherwise
.................... * the final string is returned in the endptr, if endptr is not null
.................... */
.................... float strtod(char *s,char *endptr);
....................
.................... /* Standard template: long strtoul(char * s,char *endptr,signed int base)
.................... * converts the initial portion of the string s, represented as an
.................... * integral value of radix base to a signed long.
.................... * Returns the converted value if any, 0 otherwise
.................... * the final string is returned in the endptr, if endptr is not null
.................... */
.................... signed long strtol(char *s,char *endptr,signed int base);
....................
.................... /* Standard template: long strtoul(char * s,char *endptr,signed int base)
.................... * converts the initial portion of the string s, represented as an
.................... * integral value of radix base to a unsigned long.
.................... * returns the converted value if any, 0 otherwise
.................... * the final string is returned in the endptr, if endptr is not null
.................... */
.................... long strtoul(char *s,char *endptr,signed int base);
....................
.................... //---------------------------------------------------------------------------
.................... // Pseudo-random sequence generation functions
.................... //---------------------------------------------------------------------------
....................
.................... /* The rand function computes a sequence of pseudo-random integers in
.................... * the range 0 to RAND_MAX
.................... *
.................... * Parameters:
.................... * (none)
.................... *
.................... * Returns:
.................... * The pseudo-random integer
.................... */
.................... long rand(void);
....................
.................... /* The srand function uses the argument as a seed for a new sequence of
.................... * pseudo-random numbers to be returned by subsequent calls to rand.
.................... *
.................... * Parameters:
.................... * [in] seed: The seed value to start from. You might need to pass
.................... *
.................... * Returns:
.................... * (none)
.................... *
.................... * Remarks
.................... * The srand function sets the starting point for generating
.................... * a series of pseudorandom integers. To reinitialize the
.................... * generator, use 1 as the seed argument. Any other value for
.................... * seed sets the generator to a random starting point. rand
.................... * retrieves the pseudorandom numbers that are generated.
.................... * Calling rand before any call to srand generates the same
.................... * sequence as calling srand with seed passed as 1.
.................... * Usually, you need to pass a time here from outer source
.................... * so that the numbers will be different every time you run.
.................... */
.................... void srand(unsigned int32 seed);
....................
.................... //---------------------------------------------------------------------------
.................... // Memory management functions
.................... //---------------------------------------------------------------------------
....................
.................... // Comming soon
....................
.................... //---------------------------------------------------------------------------
.................... // Communication with the environment
.................... //---------------------------------------------------------------------------
....................
.................... /* The function returns 0 always
.................... */
.................... signed int system(char *string);
....................
.................... //---------------------------------------------------------------------------
.................... // Searching and sorting utilities
.................... //---------------------------------------------------------------------------
....................
.................... /* Performs a binary search of a sorted array..
.................... *
.................... * Parameters:
.................... * [in] key: Object to search for
.................... * [in] base: Pointer to base of search data
.................... * [in] num: Number of elements
.................... * [in] width: Width of elements
.................... * [in] compare: Function that compares two elements
.................... *
.................... * Returns:
.................... * bsearch returns a pointer to an occurrence of key in the array pointed
.................... * to by base. If key is not found, the function returns NULL. If the
.................... * array is not in order or contains duplicate records with identical keys,
.................... * the result is unpredictable.
.................... */
.................... //void *bsearch(const void *key, const void *base, size_t num, size_t width,
.................... // int (*compare)(const void *, const void *));
....................
.................... /* Performs the shell-metzner sort (not the quick sort algorithm). The contents
.................... * of the array are sorted into ascending order according to a comparison
.................... * function pointed to by compar.
.................... *
.................... * Parameters:
.................... * [in] base: Pointer to base of search data
.................... * [in] num: Number of elements
.................... * [in] width: Width of elements
.................... * [in] compare: Function that compares two elements
.................... *
.................... * Returns:
.................... * (none)
.................... */
.................... //void *qsort(const void *base, size_t num, size_t width,
.................... // int (*compare)(const void *, const void *));
....................
.................... //---------------------------------------------------------------------------
.................... // Integer arithmetic functions
.................... //---------------------------------------------------------------------------
....................
.................... #define labs abs
....................
.................... div_t div(signed int numer,signed int denom);
.................... ldiv_t ldiv(signed long numer,signed long denom);
....................
.................... //---------------------------------------------------------------------------
.................... // Multibyte character functions
.................... //---------------------------------------------------------------------------
....................
.................... // Not supported
....................
.................... //---------------------------------------------------------------------------
.................... // Multibyte string functions
.................... //---------------------------------------------------------------------------
....................
.................... // Not supported
....................
....................
.................... //---------------------------------------------------------------------------
.................... // Internal implementation
.................... //---------------------------------------------------------------------------
....................
.................... #include <stddef.h>
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (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 ////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -