完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我在选择PIC18F45 50的MSSP模块作为I2C或SPI时遇到了一些困难,哪个寄存器选择了这个?问候,Akshay
以上来自于百度翻译 以下为原文 Hi, I am facing some difficulty while selecting MSSP module of PIC18F4550 as I2C or SPI.Which register selects this? Regards, Akshay |
|
相关推荐
19个回答
|
|
你看过数据表了吗?这应该永远是您的第一个资源。
以上来自于百度翻译 以下为原文 Have you read the Datasheet? This should always be your first resource. http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf Try section 19. 19.0 MASTER SYNCHRONOUS SERIAL PORT (MSSP) MODULE |
|
|
|
|
|
|
|
SSPM3:SSPM0:主同步串行端口模式选择BITS0101= SPI从模式,时钟=SCK引脚,SS引脚控制禁用,SS可以用作I/O引脚(3)0100=SPI从属模式,时钟=SCK引脚,SS引脚控制启用(3)0011=SPI主模式,时钟=TMR2输出/ 2(3,4)0010=SPI主模式,CLCK= F OSC/64(3)0001=SPI主模式、时钟=F OSC/16(3)0000=SPI主模式、时钟=F OSC/4(3),这些是SSPCON1的最后4位。这不说明如何选择SPI或I2C。
以上来自于百度翻译 以下为原文 SSPM3:SSPM0: Master Synchronous Serial Port Mode Select bits 0101 = SPI Slave mode, clock = SCK pin, SS pin control disabled, SS can be used as I/O pin (3) 0100 = SPI Slave mode, clock = SCK pin, SS pin control enabled (3) 0011 = SPI Master mode, clock = TMR2 output/2 (3,4) 0010 = SPI Master mode, clock = F OSC /64 (3) 0001 = SPI Master mode, clock = F OSC /16 (3) 0000 = SPI Master mode, clock = F OSC /4 (3) These are the last 4 bits of SSPCON1.This doesnt tell how to select SPI or I2C |
|
|
|
注意,只有6个值。在I2C部分中,这些位的更多值被解释为:SSPM3:SSPM0:主同步串行端口模式选择BITS1111=I2C从模式,10位地址具有开始和停止位中断,允许1110= I2C从模式,7位地址具有开始和停止位接口。Rrutts启用(2)1011=I2C固件控制主模式(从属空闲)(2)1000=I2C主模式,时钟=FoC//(4×(SSPADD+1))(2,3)0111=I2C从属模式,10位ADDISSRES0110= I2C从模式,7位地址读取数据表。
以上来自于百度翻译 以下为原文 Note that that's only 6 values. In the I2C section, more values for those bits are accounted for: SSPM3:SSPM0: Master Synchronous Serial Port Mode Select bits 1111= I2C Slave mode, 10-bit address with Start and Stop bit interrupts enabled 1110= I2C Slave mode, 7-bit address with Start and Stop bit interrupts enabled(2) 1011= I2C Firmware Controlled Master mode (slave Idle)(2) 1000= I2C Master mode, clock = FOSC/(4 * (SSPADD + 1))(2,3) 0111= I2C Slave mode, 10-bit address 0110= I2C Slave mode, 7-bit address Read the Datasheet. |
|
|
|
是的。很好。低4位可以将它设置为I2C或SPI.SPI为单字节发送和接收工作。如果我想发送多字节。应该检查哪个标志来检查先前的字节是否被传输。
以上来自于百度翻译 以下为原文 Yes.Its fine.Lower 4 bits can set it as I2C or SPI. SPI works for single byte transmission and reception.If I want to send multi-byte.Which flag should i check to check whether previous byte is transferred or not. |
|
|
|
SSPIF既适用于发射机又适用于接收机。如何区分TX和RX这一标志。这真的令人困惑。
以上来自于百度翻译 以下为原文 SSPIF is for both transmitter and receiver.How do i distinguish between tx and rx wit this flag.It really makes confusion.sad: |
|
|
|
这是因为,QHB总是声明SPI事务本质上总是*tx和rx同时进行!
以上来自于百度翻译 以下为原文 It's because, as QHB always states SPI transaction are inherently *always* tx and rx at the same time! |
|
|
|
我有一个可爱的反应,如何使用SSP,如果与I2C,但我得到什么,但访问拒绝错误……这么多,我猜*耸肩*伟大的论坛软件。
以上来自于百度翻译 以下为原文 I had a lovely response typed up on how to use the SSP IF with I2C, but I get nothing but access denied errors so.... So much for that I guess *shrug* Great forum software. |
|
|
|
是的,SPI是一个全双工系统,同时发送和接收同一个时钟。
以上来自于百度翻译 以下为原文 Yep, SPI is a full-duplex system, transmitting and receiving with the same clock at the same time. |
|
|
|
我已经被击败了,但是为了加强这一点,SPI总是一个发送和接收。你不能只做一个或另一个。这就是为什么只有一面旗帜。
以上来自于百度翻译 以下为原文 I've been beaten to the punch, but just to reinforce the point, SPI is always BOTH a send and a receive. You can NOT do only one or the other. That's why there is only one flag. |
|
|
|
在每次写入字节时使用中断发送多字节,它将把SSPIF设置为1,当SSPIF设置为1时,如何处理这种情况?SPI是全双工。虚中断ISR(){if(SSPIF==1)/ /它是接收还是发送中断?{}
以上来自于百度翻译 以下为原文 while transmitting multibyte using interrupt as everytime byte is written it will set SSPIF to 1.and when data is received SSPIF set to 1.How can i handle this situation?SPI is full duplex. void interrupt ISR() { if(SSPIF==1) // Whether it is receive or transmit interrupt? { } } |
|
|
|
这是错误的。SSPIF直到完整传输完成才被设置。此时,发送字节已经被发送,并且接收字节已经被接收。
以上来自于百度翻译 以下为原文 This is wrong. SSPIF is not set until the full transfer is complete. At that time, the transmit byte has been sent, and the receive byte has been received. |
|
|
|
这是错误的。SSPIF直到完整传输完成才被设置。这时,发送字节已经被发送,接收字节已经被接收。在中断例程中,我如何处理它?
以上来自于百度翻译 以下为原文 This is wrong. SSPIF is not set until the full transfer is complete. At that time, the transmit byte has been sent, and the receive byte has been received. In interrupt routine,How do I handle it? |
|
|
|
以上来自于百度翻译 以下为原文 void SendString(unsigned char * str) { while(str) { SSPBUF=*str str++; while(SSPIF==0) } } |
|
|
|
您询问了一个中断程序,然后张贴了一些不使用中断例程的代码。代码中有一些错误。试试这个:或者你可以用BF旗做同样的事情。
以上来自于百度翻译 以下为原文 You asked about an interrupt routine, then posted some code that does not use an interrupt routine. There are some mistakes in your code. Try this: void SendString(unsigned char * str) { while(*str) { SSPIF=0; //clear SSPIF SSPBUF=*str++; while(SSPIF==0); //SSPIF will be set when transfer completes. } } Or you can do the same thing using the BF flag void SendString(unsigned char * str) { while(*str) { SSPBUF; //dummy read to clear BF SSPBUF=*str++; while(BF==0); //BF will be set when transfer is complete } } |
|
|
|
如果SSPIF因为接收字节而不设置字节,那该怎么办?问候,Akshay
以上来自于百度翻译 以下为原文 What if SSPIF is set by receiving byte not because of transmitting byte? Regards, Akshay |
|
|
|
你似乎还不知道每一个SPI传输都是同时发送和接收的。上面的代码也在接收数据,它只是不使用它。就外围设备而言,发送和接收没有区别。VEN,然后只发送0x00或0xFF字节。
以上来自于百度翻译 以下为原文 You still don't seem to understand that EVERY SPI transfer is a simultaneous send and receive. The above code is also receiving data, it's just not using it. There is NO DIFFERENCE between sending and receiving as far as the peripheral is concerned. If it doesn't matter what you send when you're receiving, then just send 0x00 or 0xFF bytes. |
|
|
|
有些人发现,如果创建一个函数来传递一个字节,那么这更容易理解:
以上来自于百度翻译 以下为原文 Some people find this easier to understand if you create a single function to transfer one byte each way: unsigned char spi_xfer(unsigned char dat) { SSPIF=0; //clear SSPIF SSPBUF=dat; //send byte while(SSPIF==0); //SSPIF will be set when transfer completes. return SSPBUF; //read byte that was received and return it } void SendString(unsigned char * str) { while(*str) spi_xfer(*str++); } |
|
|
|
以上来自于百度翻译 以下为原文 unsigned char spi_xfer(unsigned char dat) { SSPIF=0; //clear SSPIF SSPBUF=dat; //send byte while(SSPIF==0); //SSPIF will be set when transfer completes. return SSPBUF; //read byte that was received and return it } Now it is quiet clear to me. What will it receive when slave doesn't send data? |
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3214 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2261 浏览 5 评论
781浏览 1评论
676浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
602浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
684浏览 0评论
581浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 08:25 , Processed in 1.607732 second(s), Total 84, Slave 78 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号