📄 spi_master_no_ss.lst
字号:
C51 COMPILER V7.10 SPI_MASTER_NO_SS 04/30/2004 15:23:37 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE SPI_MASTER_NO_SS
OBJECT MODULE PLACED IN spi_master_no_ss.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE spi_master_no_ss.c BROWSE DEBUG OBJECTEXTEND TABS(3)
line level source
1 /**
2 * @file $RCSfile: spi_master_no_ss.c,v $
3 *
4 * Copyright (c) 2004 Atmel.
5 *
6 * Please read file license.txt for copyright notice.
7 *
8 * @brief This file is an example to use spi in master mode.
9 *
10 * This file can be parsed by Doxygen for automatic documentation
11 * generation.
12 * Put here the functional description of this file within the software
13 * architecture of your program.
14 *
15 * @version $Revision: 1.0 $ $Name: $
16 */
17
18 /* @section I N C L U D E S */
19 #include "reg_c51.h"
20 char serial_data;
21 char data_example=0x55;
22 char data_save;
23 bit transmit_completed= 0;
24
25 /**
26 * FUNCTION_PURPOSE: This file set up spi in master mode with
27 * Fclk Periph/128 as baud rate and without slave select pin
28 * FUNCTION_INPUTS: P1.5(MISO) serial input
29 * FUNCTION_OUTPUTS: P1.7(MOSI) serial output
30 * P1.1
31 */
32 void main(void)
33 {
34 1 SPCON |= 0x10; /* Master mode */
35 1 SPCON |= 0x82; /* Fclk Periph/128 */
36 1 SPCON |= 0x20; /* P1.1 is available as standard I/O pin */
37 1 SPCON &= ~0x08; /* CPOL=0; transmit mode example */
38 1 SPCON |= 0x04; /* CPHA=1; transmit mode example */
39 1 IEN1 |= 0x04; /* enable spi interrupt */
40 1 SPCON |= 0x40; /* run spi */
41 1 EA=1; /* enable interrupts */
42 1
43 1 while(1) /* endless */
44 1 {
45 2 P1_1=~P1_1; /* P1.1 is available as standard I/O pin */
46 2 SPDAT=data_example; /* send an example data */
47 2 while(!transmit_completed);/* wait end of transmition */
48 2 transmit_completed = 0; /* clear software transfert flag */
49 2
50 2 SPDAT=0x00; /* data is send to generate SCK signal */
51 2 while(!transmit_completed);/* wait end of transmition */
52 2 transmit_completed = 0; /* clear software transfert flag */
53 2 data_save = serial_data; /* save receive data */
54 2 }
55 1
C51 COMPILER V7.10 SPI_MASTER_NO_SS 04/30/2004 15:23:37 PAGE 2
56 1 }
57
58
59 /**
60 * FUNCTION_PURPOSE:interrupt
61 * FUNCTION_INPUTS: void
62 * FUNCTION_OUTPUTS: transmit_complete is software transfert flag
63 */
64 void it_SPI(void) interrupt 9 /* interrupt address is 0x004B */
65 {
66 1 switch ( SPSTA ) /* read and clear spi status register */
67 1 {
68 2 case 0x80:
69 2 serial_data=SPDAT; /* read receive data */
70 2 transmit_completed=1;/* set software flag */
71 2 break;
72 2
73 2 case 0x10:
74 2 /* put here for mode fault tasking */
75 2 break;
76 2
77 2 case 0x40:
78 2 /* put here for overrun tasking */
79 2 break;
80 2 }
81 1 }
82
83
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 74 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 3 ----
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -