发 帖  
原厂入驻New
张飞60小时讲透半桥串联谐振软开关电源设计,立即学习!
[问答] PIC18F46K22死锁作为SPI sla
269 SPI USB MPLAB
分享
大家好,我在MSSP1上使用相关的PIC作为SPI奴隶。主机是一个MCP2210,所以我通过USB不断传输数据。然后通过SPI将接收到的数据通过MSSP2移动到外部的32 K×8位RAM单元。整个系统工作时间可变(从一小时到多小时),突然微控制器陷入死锁。我用MPLAB代码配置器在很多方面配置了时钟。它目前运行在64 MHz的HFIFToSC和软件PLL(4X),因此内部时钟是16 MHz,但它也死锁在32 MHz(8MHz HFIFTSOC)。MSSP2被用作SPI主机来驱动外部RAM存储器。它配置在模式0中,在4 MHz的SPI时钟和在脉冲的中间采样(我也尝试了在脉冲的末尾采样)。我已经配置了外部MCP2210以多种方式,从10 MHz到1 MHz的速度,并且在CS线变低之后添加了大约500个USEC的延迟。以前很高。我还应用了50字节的字节间延迟,但是这当然会在通信中产生不希望的高延迟。总之,过了一段时间后,微控制器就被冻结了。我已经在这个问题上挣扎了大约两个月的漫长的夜晚,相信我,我已经尝试了很多组合的选择。我的PIC的修订ID是4,所以我已经检查了勘误表文档,似乎这次修订有一些关于MSSP模块的问题,但在硕士。模式(缓冲器满(BF)位或MSSP中断标志(SSPIF)位太早设置为半SCK周期),但在从属模式中没有。当触发MSSP1中断时,我总是按以下方式处理ISR:μSmiMs= SSP1BUF;/这里,“μSICMD”通过MS发送到外部RAM输出队列。SP2和/或一些数据可以从RAM输入队列SSP1BUF=SpRMD中读取;如果(SSP1CON1BIT.WCOL){SSP1CON1BIT.WCOL=μRead;SSP1BUF=SARMMD;}(SSP1CON1BSP.SSPV)SSP1CON1BIT.SSPV==重置;SPI1A CurrySnInStasuSuBIT;我将MSSP1配置为从属方式:EnabelItSPI1;SETPRIORItiONITSPI1(μSET);//SPI从属/模式0 /样本在脉冲OpenSPI1的中间(SLVI SSON,MODE00 00,SMPMID);你有没有经历过这方面的事情?你能告诉我是否有另一个硅错误有关这一点的PIC或有什么东西,我需要更好地配置?谢谢您!

以上来自于百度翻译


      以下为原文

    Hello guys, I'm using the related PIC as SPI slave on the MSSP1. The master is a MCP2210 so I'm continuously transferring data via USB. The received data is then moved via MSSP2 to an external 32K x 8bit RAM unit via SPI.

The whole system works peRFectly for a variable time (from one hour to many hours), and suddenly the microcontroller gets into deadlock.

I've configured the clock in many ways by using MPLAB Code Configurator. It is currently running using the HFINTOSC and software PLL (4x) at 64 MHz, so the internal clock is 16 MHz, but it also deadlock at 32 MHz (8MHz HFINTOSC).

The MSSP2 is used as SPI MASTER to drive the external RAM Memory. It is configured in Mode 0 with a SPI Clock at 4 MHz and sampling in the middle of the of the pulse (I've also tried sampling at the end of the pulse).

I've configured the external MCP2210 in many ways with speeds from 10 MHz to 1 MHz and adding delays of almost 500 uSec after the CS line goes LOW and before goes HIGH. I've also applied inter-byte delays of 50 uS, but this of course yields an undesirable high latency on the communication.

Anyway, after some time the Microcontroller just freeze. I've been struggling with this problem for about two months of long nights and believe me, I've tried a lot of combination of options.

The Revision ID of my PIC is 4, so I've checked the Errata Document and it seems that for this revision there are some issues regarding the MSSP module but in Master Mode (Buffer Full (BF) bit or MSSP Interrupt Flag (SSPIF) bit becomes set half SCK cycle too early.) but nothing in Slave Mode.

When the MSSP1 interrupt is triggered I always handle the ISR the following way:

_spicmd = SSP1BUF;
//Here the "_spicmd" is sent to the external RAM output Queue by using MSSP2 and
//some data could be read from the RAM input Queue
SSP1BUF = _spicmd;
if(SSP1CON1bits.WCOL)
{
SSP1CON1bits.WCOL = _RESET;
SSP1BUF = _spicmd;
}

if(SSP1CON1bits.SSPOV)
SSP1CON1bits.SSPOV = _RESET;

SPI1_Clear_Intr_Status_Bit;

I configure the MSSP1 as Slave the following way:

EnableIntSPI1;
SetPriorityIntSPI1(_SET);
//SPI Slave / Mode 0 / Sample at the middle of the pulse
OpenSPI1(SLV_SSON, MODE_00, SMPMID);

Have ever you experienced something regarding this? Could you please aDVIse if there is another silicon bug regarding this on this reference of PIC or is there something that I need to configure better?

Thank you!

0
2018-11-28 16:41:49   评论 分享淘帖 邀请回答
5个回答
这是什么意思?程序在哪里停止?它在等待着从未发生过的事情吗?用你所提供的信息,我会说你有一个或多个不正确的代码段,但是在哪里?不知道,因为我们还没见过。

以上来自于百度翻译


      以下为原文

   
What does this really mean? Where in the program is it stopping? Is it waiting for something that never happens? With the info you have given I would say you have one or more incorrect sections of code but where? Don't know because we haven't seen it.
2018-11-28 16:47:44 评论

举报

从你的帖子来看,你已经在代码中复制了,但是我不确定前两行(和它们之间的注释)有多大意义。MSSP1是否回送它接收的每个字符?我建议你展示你所有的代码(或者更好的是,一个小而完整的应用程序的代码显示问题)完成配置设置。一个常见的问题是你在ISR上花费了太长的时间(一些未指定的条件),但是没有C我们就无法判断。苏珊颂歌

以上来自于百度翻译


      以下为原文

    By the look of your posting, you have copied in the code but I'm not sure that the first two lines (and the comment in between them) make much sense. Does MSSP1 echo back every character that it receives?
I suggest that you show us all of your code (or better still, the code of a small but complete app that exhibits the problem) complete with the config settings.
A common problem is that you are spending too long in the ISR on some (unspecified) condition but there is no way we can tell without the code.
Susan
2018-11-28 16:53:37 评论

举报

大家好,谢谢你们的关心和时间!我在每个模块上运行了一些单元测试来检查它们的响应能力。我已经测试了数据接收作为SPI从机,它已经连续运行了两天!我已经从ISR中删除了一些额外的负担,关于与外部RAM内存的通信(使用MSSP2作为SPI主控器)。我在ISR中首先缓冲内部RAM。然后,在主循环中处理缓冲数据。在这一点上,我不确定这个问题是不是与在勘误表中解释的硅错误或者在ISR中处理太长,正如苏珊指出的,或者两者都可能。无论如何,我会给你这个反馈,一旦我得到解决方案,谢谢!

以上来自于百度翻译


      以下为原文

    Hello guys, thanks for your concern and time! I've been running some sort of unit tests on every module checking their responsabilities. I've tested the data reception as SPI slave and It has been running for two days continuosly! I've removed some extra burden from the ISR regarding the communication with the external RAM memory (done by using the MSSP2 as SPI Master). I'm buffering to the internal RAM first in the ISR. Then I process the buffered data in the main loop. At this point I'm not sure if the problem has to do with the silicon bug explained in the Errata or just a too long processing in the ISR as Susan pointed or maybe the both of them! Anyway guys I will give you feedback on this once I get the solution, thanks!
2018-11-28 16:59:53 评论

举报

当Ext RAM变满时会发生什么?你确定它已经锁上了吗?每秒闪光一次LED,以验证时间,没有,奴隶将保持主人等待。这是锁定功能。在SPI功能中设置看门狗定时器,一旦交换完成,就禁用它。如果你重置一次,就为你创建的每一个错误代码闪出一个LED X倍。S可能已经崩溃。从微芯片下载它,它是16位,但是文档是详细的。第18节。串行外围接口(SPI)

以上来自于百度翻译


      以下为原文

    What happens when the ext. ram becomes full?
 
Are you sure it has locked?  Flash an led once every second to verify.
 
Timing, none, the slave will keep the master waiting.  This is the lockout.
Setup watchdog timer in your spi functions then disable once exchange complete.
If you get a reset, flash an led x amount of times for each error code you create.
 
S could have crashed.
 
Download that from MicroChip, it is 16bit but the documentation is detailed.
Section 18. Serial Peripheral Interface (SPI)
 
2018-11-28 17:09:43 评论

举报

您好,谢谢您的时间和关切。EXT RAM由我自制的队列控制器控制。它格式化内存空间并连续检查其边界。如果满,它将停止写入(不允许循环重写)。我已经成功地在许多项目中完成了这个代码。我正在考虑关于MSSP作为主机的硅错误,因为如果我将主SPI总线减速到1 MHz,它也会在某个时间点冻结微控制器。关于看门狗,我不使用它,因为我希望事情正常工作,没有蛮力。我想说清楚一点,RAM的MEM(SPI Master)是被访问的,而SPI从属设备接收一个字节,所以在这一点上,主机是在ISR中阻止从属的,因为该字节立即被移动到RAM。

以上来自于百度翻译


      以下为原文

    Hello and thanks for your time and concern. The ext RAM is controlled by a Queuing Controller that I made myself. It formats the memory space and continuosly checks its boundaries. If full, it will stop writting (no circular overwrite is allowed). I've worked this code in many projects successfully. I'm thinking of the silicon bug regarding the MSSP as master, since it doesn't matter if I slowdown the Master SPI bus to 1 MHz, it also freezes the Microcontroller at some point in time. Regarding the watchdog, I'm not using it since I want the thing to work properly without brute force. I want to make something clear, the RAM mem (SPI Master) is accessed while the SPI Slave receives a byte, so at this point the Master is the one blocking the Slave in the ISR, since that byte is moved to RAM immediately.
2018-11-28 17:29:31 评论

举报

只有小组成员才能发言,加入小组>>

42个成员聚集在这个小组

加入小组

创建小组步骤

关闭

站长推荐 上一条 /10 下一条

快速回复 返回顶部 返回列表