当前位置:网站首页>Ch549/ch548 learning notes 5 - SPI main mode
Ch549/ch548 learning notes 5 - SPI main mode
2022-07-19 16:13:00 【pq113_ six】
Catalog
CH549/CH548 Have 1 A hardware SPI Interface , Support master / Slave mode , Only the main mode is discussed here . in addition ,SPI The main mode only supports mode 0 And pattern 3, Consider commonality , Only set to mode 0.
1. clock frequency
CH549/CH548 Through registers SPI0_CK_SE( The default is 0x20) Set the frequency , Up to half of the main frequency of the system .datasheet The calculation formula is not stated in , Guess it is
freq = Fsys / (SPI0_CK_SE + 1)
2. IO Set up
P1_MOD_OC &= ~(bMOSI | bSCK);
P1_DIR_PU |= (bMOSI | bSCK); //SCS, MOSI, SCK Set push-pull output
P1_MOD_OC |= bMISO; //MISO Pull up input
P1_DIR_PU |= bMISO;here CS The feet are P1.4, Actually, it can be replaced by any IO,SCS Function is used for slave mode .
3. SPI0_SETUP Set up
Valid bits in main mode :

Generally, interrupt is not used , It's usually MSB High in the former , So these bits are 0.
4. SPI0_CTRL

Set up MOSI and SCK For export ( position 6 And place 5 Set to 1), Pattern 0( position 3 Set to 0), Three wire mode ( position 2 Set to 0)
SPI0_CTRL = (bS0_MOSI_OE | bS0_SCK_OE);5. Read and write data
SPI0_DATA = (wrBuf != NULL) ? wrBuf[i] : 0xff;
while(S0_FREE == 0);
if(rdBuf != NULL)
rdBuf[i] = SPI0_DATA;SPI It's full duplex , So the read-write synchronization is completed .SPI0_DATA Registers are physically separate FIFO, The reading operation corresponds to
Receive data FIFO; Write operation corresponds to sending data FIFO.
S0_FREE It's a register SPI0_STAT Bit 3, Addressable addressing

边栏推荐
- Liquibase学习3 - logLevel日志等级、常用命令
- Is flush stock trading safe?
- Amy's thinking
- ffifdyop绕过MD5进行sql注入
- Solve the problem of "license manager error -8" after matlab installation (the personal test is valid)
- About the problem that only one IP can be accessed after dual network cards are configured
- 投资和生活分开
- Identity server 4 uses openid connect to add user authentication (3)
- 第一个接受素数定理的人
- Use of promise object in ES6 asynchronous programming
猜你喜欢

MySQL - 表字段的自增约束

VOS客户端上服务器和软交换状态显示红灯的原因分析

First knowledge of convolution +matlab's intuitive understanding of discrete convolution process

【深度学习基础】如何理解卷积神经网络中的通道channel
![[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference](/img/0f/8ce2d5487b16d38a152cfd3ab454bb.png)
[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference

Pwnthebox, Web: Double - S

PwnTheBox,Web:Double-S

解决MATLAB安装后出现 “License Manager Error -8”(亲测有效)

Solidworks装配体常见问题汇总(随时更新)

2022/07 CSI tool installation process record
随机推荐
[MCU simulation project] LED flashing light (Proteus schematic +keil code)
QT | qcombobox of control
读书笔记:程序员的自我修养---第二章
Hash table related knowledge
[MCU simulation project] alarm light (Proteus schematic diagram +keil code)
手写简易Promise代码注释
【干货】MySQL底层架构设计,你了解多少?
hcia--OSPF实验报告
Solve the problem of "license manager error -8" after matlab installation (the personal test is valid)
Liquibase学习1 - 安装、简单使用
Thinking and speculation on passing based on binary tree
Financial banking software testing super large strategy, the most popular financial banking big secret cover questions
ffifdyop绕过MD5进行sql注入
[dry goods] how much do you know about MySQL infrastructure design?
How to rewrite hashcode method correctly?
Is online fund account opening safe? Find the answer online
Mogdb/opengauss permission collation
【深度学习基础】如何理解卷积神经网络中的通道channel
CH549/CH548学习笔记6 - 读取芯片ID
【深度学习基础】卷积是如何计算的