//-----------------------------------------------------------------------------
// F02x_SMBus_EEPROM.c
//-----------------------------------------------------------------------------
// 此程序由【达达电子工作】的 RJ 整理 我们对此无版权
// 我们的淘宝网店: http://dadastudio.taobao.com/
// 关于此例程请参考 C8051F2xx中文版.pdf 的第 18 章:SMBUS
//
// Copyright 2006 Silicon Laboratories, Inc.
// http://www.silabs.com
//
// Program Description:
//
// This example demonstrates how the C8051F02x SMBus interface can communicate
// with a 256 byte I2C Serial EEPROM (Microchip 24LC02B).
// - Interrupt-driven SMBus implementation
// - Only master states defined (no slave or arbitration)
// - Timer3 used by SMBus for SCL low timeout detection
// - SCL frequency defined by <SMB_FREQUENCY> constant
// - Pinout:
// P0.0 -> SDA (SMBus)
// P0.1 -> SCL (SMBus)
//
// P1.6 -> LED
//
// all other port pins unused
//
// How To Test:
//
// 1) Download code to a 'F02x device that is connected to a 24LC02B serial
// EEPROM (see the EEPROM datasheet for the pinout information).
// 2) Run the code:
// a) the test will indicate proper communication with the EEPROM by
// turning on the LED at the end the end of the test
// b) the test can also be verified by running to the if statements
// in main and checking the sent and received values by adding
// the variables to the Watch Window
//
// FID: 02X000009
// Target: C8051F02x
// Tool chain: Keil C51 7.50 / Keil EVAL C51
// Command Line: None
//
// Release 1.0
// -Initial Revision (TP)
// -20 APR 2006
//
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <C8051F020.h> // SFR declarations
//-----------------------------------------------------------------------------
// Global CONSTANTS
//-----------------------------------------------------------------------------
#define SYSCLK 4000000L // System clock frequency in Hz
#define SMB_FREQUENCY 10000L // Target SCL clock rate
// This example supports between 10kHz
// and 100kHz
#define WRITE 0x00 // WRITE direction bit
#define READ 0x01 // READ direction bit
// Device addresses (7 bits, lsb is a don't care)
#define EEPROM_ADDR 0xA0 // Device address for slave target
// Note: This address is specified
// in the Microchip 24LC02B
// datasheet.
#define MY_ADDR 0x02 // Address of this SMBus device
// (dummy value since this device does
// not have any defined slave states)
// SMBus Buffer Size
#define SMB_BUFF_SIZE 0x08 // Defines the maximum number of bytes
// that can be sent or received in a
// single transfer
#define SMB_BUS_ERROR 0x00 // (all modes) BUS ERROR
#define SMB_START 0x08 // (MT & MR) START transmitted
#define SMB_RP_START 0x10 // (MT & MR) repeated START
#define SMB_MTADDACK 0x18 // (MT) Slave address + W transmitted;
// ACK received
#define SMB_MTADDNACK 0x20 // (MT) Slave address + W transmitted;
// NACK received
#define SMB_MTDBACK 0x28 // (MT) data byte transmitted;
// ACK rec'vd
#define SMB_MTDBNACK 0x30 // (MT) data byte transmitted;
// NACK rec'vd
#define SMB_MTARBLOST 0x38 // (MT) arbitration lost
#define SMB_MRADDACK 0x40 // (MR) Slave address + R transmitted;
// ACK received
#define SMB_MRADDNACK 0x48 // (MR) Slave address + R transmitted;
// NACK received
#define SMB_MRDBACK 0x50 // (MR) data byte rec'vd;
// ACK transmitted
#define SMB_MRDBNACK 0x58 // (MR) data byte rec'vd;
// NACK transmitted
//-----------------------------------------------------------------------------
// Global VARIABLES
//-----------------------------------------------------------------------------
unsigned char* pSMB_DATA_IN; // Global pointer for SMBus data
// All receive data is written here
unsigned char SMB_SINGLEBYTE_OUT; // Global holder for single byte writes.
unsigned char* pSMB_DATA_OUT; // Global pointer for SMBus data.
// All transmit data is read from here
unsigned char SMB_DATA_LEN; // Global holder for number of bytes
// to send or receive in the current
// SMBus transfer.
unsigned char WORD_ADDR; // Global holder for the EEPROM word
// address that will be accessed in
// the next transfer
unsigned char TARGET; // Target SMBus slave address
bit SMB_BUSY = 0; // Software flag to indicate when the
// EEPROM_ByteRead() or
// EEPROM_ByteWrite()
// functions have claimed the SMBus
bit SMB_RW; // Software flag to indicate the
// direction of the current transfer
bit SMB_SENDWORDADDR; // When set, this flag causes the ISR
// to send the 8-bit <WORD_ADDR>
// after sending the slave address.
bit SMB_RANDOMREAD; // When set, this flag causes the ISR
// to send a START signal after sending
// the word address.
// For the 24LC02B EEPROM, a random read
// (a read from a particular address in
// memory) starts as a write then
// changes to a read after the repeated
// start is sent. The ISR handles this
// switchover if the <SMB_RANDOMREAD>
// bit is set.
bit SMB_ACKPOLL; // When set, this flag causes the ISR
// to send a repeated START until the
// slave has acknowledged its address
// 16-bit SFR declarations
sfr16 TMR3RL = 0x92; // Timer3 reload registers
sfr16 TMR3 = 0x94; // Timer3 counter registers
sbit LED = P1^6; // LED on P1.6
sbit SDA = P0^0; // SMBus on P0.0
sbit SCL = P0^1; // and P0.1
//-----------------------------------------------------------------------------
// Function PROTOTYPES
//-----------------------------------------------------------------------------
void Port_Init(void);
void SMBus_Init(void);
void Timer3_Init(void);
void SMBus_ISR(void);
void
没有合适的资源?快使用搜索试试~ 我知道了~
C8051F020 120开发板资料 C8051F020keil编译例程.rar
共443个文件
bak:79个
plg:36个
hex:36个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 20 浏览量
2023-04-17
16:13:39
上传
评论 1
收藏 744KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
C8051F020 120开发板资料 C8051F020keil编译例程.rar (443个子文件)
Test_uvopt.bak 56KB
Test_uvopt.bak 54KB
Test_uvproj.bak 13KB
Test.Uv2.bak 2KB
Test.Uv2.bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Uv2.Bak 2KB
Test_Opt.Bak 2KB
Test.opt.bak 2KB
Test.opt.bak 1KB
Test_Opt.Bak 1KB
Test_Opt.Bak 1017B
Test_Opt.Bak 1001B
Test_Opt.Bak 983B
Test_Opt.Bak 891B
Test_Opt.Bak 887B
Test_Opt.Bak 885B
Test_Opt.Bak 885B
Test_Opt.Bak 885B
Test_Opt.Bak 883B
Test_Opt.Bak 883B
Test_Opt.Bak 883B
Test_Opt.Bak 881B
Test_Opt.Bak 881B
Test_Opt.Bak 881B
Test_Opt.Bak 881B
Test_Opt.Bak 879B
Test_Opt.Bak 879B
Test_Opt.Bak 879B
Test_Opt.Bak 875B
Test_Opt.Bak 875B
Test_Opt.Bak 873B
Test_Opt.Bak 873B
Test_Opt.Bak 873B
Test_Opt.Bak 870B
Test_Opt.Bak 869B
Test_Opt.Bak 869B
Test_Opt.Bak 869B
Test_Opt.Bak 865B
Test_Opt.Bak 863B
Test_Opt.Bak 863B
Test_Opt.Bak 861B
Test_Opt.Bak 861B
Test_Opt.Bak 859B
Test_Opt.Bak 851B
F02x_SMBus_EEPROM.c 32KB
F02x_SMBus_Multimaster.c 27KB
F02x_SPI0_Master.c 26KB
F02x_SMBus_Master_Multibyte.c 22KB
F02x_SPI0_EEPROM_Polled_Mode.c 20KB
F02x_ADC0_ExternalInput_Mux.c 20KB
F02x_SMBus_Master.c 20KB
F02x_SMBus_Slave_Multibyte.c 15KB
F02x_ADC0_ExternalInput.c 15KB
F02x_SPI0_Slave.c 14KB
F02x_SMBus_Slave.c 13KB
F02x_UARTs_STDIO_Polled_2UARTs.c 13KB
F02x_DACs_SineCosine.c 12KB
F02x_Watchdog.c 11KB
F02x_PCA0_Capture_Input.c 11KB
F02x_Oscillator_Capacitor.c 11KB
F02x_PCA0_Software_Timer_Blinky.c 11KB
F02x_PCA0_16Bit_PWM_Output.c 11KB
F02x_Oscillator_RC.c 11KB
F02x_UART1_Interrupt.c 10KB
F02x_PCA0_High_Speed_Output.c 10KB
共 443 条
- 1
- 2
- 3
- 4
- 5
资源评论
- z无聊2024-01-04资源不错,内容挺好的,有一定的使用价值,值得借鉴,感谢分享。
荣华富贵8
- 粉丝: 216
- 资源: 7653
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python基础学习-12匿名函数lambda和map、filter
- MATLAB实现CSO-ELM布谷鸟算法优化极限学习机多输入单输出回归预测(多指标,多图)(含完整的程序和代码详解)
- 基于Spark的电影推荐系统,包含爬虫项目、web网站、后台管理系统以及spark推荐系统详细文档+资料齐全.zip
- 基于spring-boot开发的分布式系统的反爬虫、防接口盗刷组件详细文档+资料齐全.zip
- 基于Spring boot 实现的股票基金爬虫工具详细文档+资料齐全.zip
- 基于Spark的新闻推荐系统,包含爬虫项目、web网站以及spark推荐系统详细文档+资料齐全.zip
- MATLAB实现GWO-BiLSTM-Attention多输入分类预测(含完整的程序和代码详解)
- 基于webmagic + springboot + mybatis的Java爬虫详细文档+资料齐全.zip
- MATLAB实现BES-ELM秃鹰搜索优化算法优化极限学习机多输入单输出回归预测(多指标,多图)(含完整的程序和代码详解)
- ansible使用说明
- 重磅推荐-2024最新FinOPS云成本优化最佳实践资料合集(16份).zip
- 基于sprint boot WebMagic 实现 微信公众号文章、新闻等网站文章爬取详细文档+资料齐全.zip
- MATLAB实现IBES-ELM改进的秃鹰搜索优化算法优化极限学习机多输入单输出回归预测(多指标,多图)(含完整的程序和代码详解)
- 基于SSM的爬虫系统,Spring+Spring MVC+MyBatis+Druid+Redis+MQ详细文档+资料齐全.zip
- 基于webmagic框架详细文档+资料齐全.zip
- 基于WebMagic的java爬虫,爬取知乎用户Demo详细文档+资料齐全.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功