完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我在PIC24FJ256GB110上有一个连接到外部中断的线路。我需要让系统在这条线的前缘和下降边都打断我。这是用来从外部从属设备上连接串行传输的。我想现在把它变成一个关于改变的中断已经太晚了。该板已经布置好了。升高线表示有一包数据正从串行线传送到uart 1。当从机完成后,它丢弃了线路。UART1通过MCC构建文件在中断驱动模式下运行。在外部中断例程中,我需要确定是上升沿还是下降沿发生了。我的逻辑是:inter._handler(){if(外部中断线路1是)high) //我们看到上升沿中断处理它,然后重新编程端口以在下降沿上生成中断,否则处理下降沿代码,并且重新编程外部中断以在上升沿上中断。变消极。是否可以读取中断处理程序中的中断行?这段代码不起作用,因为它永远不会进入在上升沿中断的情况,尽管您可以清楚地看到上升沿确实发生了。连续发送数据包,因此在中断发生的时候,实际端口值已经很长时间了,因为它长1.8毫秒。我试图首先读取端口E(外部中断在PE8,PE9上),但是这似乎没有反映它到达这里的情况。void_.((inter.,no_auto_psv))INT1Inter.(void){static char trash=0;if(EX_INT1_GetValue()==1)//low到high,传入数据{DeBUG3_OUT=1;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<永远不会到达这里……EX_INT2_NegativeEdgeSet();//PROGRAM FOR NEGATIVE TRIGGER reset_uart_1_state();//启用和配置uart缓冲区并启用中断}.{//1至0 EX_INT2_PositiveEdgeSet();//为上升沿中断UART1_ReadBuffer(&._._.[0],24)对其进行编程;set_uart_1_state();UART1_Inter..ble();//禁用uart接收上的中断,直到我们重新启用它们,._._.[24]=(无符号char)((毫秒>24)&0x000000000FF);._._.[25]=(无符号char)((毫秒>16)&0x000000FF);(毫秒>SurvivEdPayTeTeLe[(26)] =(无符号char)((毫秒& gt;8)& 0x000 00 000 FF);
以上来自于百度翻译 以下为原文 I have a line connected to an external interrupt on a PIC24FJ256GB110. I need to have the system interrupt me on both the leading edge and the falling edge of this line. This is used to bracket a serial transmisison from an external slave. It is to late to change this to an interrupt on change, I think. The board has already been laid out. Raising the line, is an indication that a packet of data is coming down the serial line to uart 1. When the slave has finished, it drops the line. UART1 is running in interrupt driven mode via the MCC built files. Within the external interrupt routine, I need to figure out whether a rising edge or falling edge happened. My logic wants to be: interrupt_handler() { if (the external interrupt line 1 is high) // we saw a rising edge interrupt process it, then reprogram the port to generate an interrupt on the falling edge else process the falling edge code, and reprogram the external interrupt to interrupt on a rising edge. The problem is that it always sees the external interrupt line as going negative. Is it possible to read the interrupt line within the interrupt handler? This code does not work, in that it never get into case where it was interrupted on a rising edge, though you can clearly see that the rising edge does indeed occur. With the debugger, set for a break point in both sections of the if EX_INT1_GetValue() test, it only hits the falling edge. The slave is continuously sending packets, so by the time the break happens, the actual port value is long gone, since it is 1.8 ms long. I tried reading the port E first thing in (the external interrupts are on PE8,PE9), but that does not seem to reflect what it was when it got here. void __attribute__((interrupt, no_auto_psv)) _INT1Interrupt(void) { static char trash=0; if(EX_INT1_GetValue()==1) // low to high, incoming data { DEBUG3_OUT=1; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< reset_uart_1_state(); // enable and configure uart buffer and enables interrupt } else { // 1 to 0 EX_INT2_PositiveEdgeSet(); // program it for a rising edge interrupt UART1_ReadBuffer(&received_packet_left[0], 24); reset_uart_1_state(); UART1_InterruptDisable(); // disable interrupts on uart reception until we re-enable them received_packet_left[24]= (unsigned char) ((milliseconds >> 24 ) & 0x000000FF); received_packet_left[25]= (unsigned char) ((milliseconds >> 16 ) & 0x000000FF); received_packet_left[26]= (unsigned char) ((milliseconds >> 8 ) & 0x000000FF); received_packet_left[27]= (unsigned char) ((milliseconds ) & 0x000000FF); received_state_left=RX_DONE; DEBUG3_OUT=0; } EX_INT1_InterruptFlagClear(); } |
|
相关推荐
6个回答
|
|
|
|
|
|
你能一直保持UART,这样你所要做的就是检测下降沿吗?
以上来自于百度翻译 以下为原文 Can you keep UART enabled at all times so that all you have to do is detecting the falling edge? |
|
|
|
你确定吗?我认为所有具有Rp功能的引脚(24FJ256GB110)也具有CN功能。
以上来自于百度翻译 以下为原文 You are sure ? I think all pins (24FJ256GB110) with RP functionality also have CN functionality. |
|
|
|
在消息之间需要关闭uart。消息由行变高触发,然后由行变低终止。当前这进入外部中断,被编程为在上升沿中断。我还需要它在下降沿中断,所以我可以终止数据包。因此,保持UART开放,当它看到带外消息时会引起问题。我想不让那些进入缓冲区。通过只在带内消息发生时启用uart,我就可以忽略带外消息。具体来说,RN4020蓝牙模块在不期望的时候发送东西。如何定义“EX_INT1_GetValue()”?由MCC配置器创建和定义。
以上来自于百度翻译 以下为原文 The uart needs to be shut down between messages. A message is triggered by a line going high, and terminated by the line going low. currently this comes into an external interrupt, programmed to interrupt on a rising edge. I need it to interrupt on a falling edge as well, so I can terminate the packet. So keeping the uart open, causes issues when it sees out of band messages. I want to keep those out of the buffer. By enabling the uart only when an in-band message happens, then I can ignore the out of band messages. Specificlly, the RN4020 bluetooth module sends stuff when it is not expected. How is "EX_INT1_GetValue()" defined? is created and defined by the mcc configurator. #define EX_INT1_GetValue() _RE8 |
|
|
|
对于最初的问题,我还是没有答案。为什么我不能看到中断线的状态,在输入中断例程时抓住端口,当它被编程为在上升的边缘中断,并且确实如此。抓取端口E显示该线始终为0。它至少为2毫秒高,所以立即抓取应该可以看到。当外部中断控制器控制一个引脚时,该引脚可以在中断例程中被读取,还是不再可见?
以上来自于百度翻译 以下为原文 I still don't have an answer to the original question. Why can't I see the status of the interrupt line, by grabbing the port on entry into the interrupt routine, when it is programmed to interrupt on a rising edge, and it does. Grabbing Port E shows the line to be 0 all the time. It is high for at least 2 msec, so an instant grab should see it. When the external interrupt controller has control of a pin, can the pin be read in the interrupt routine, or is it no longer visible? |
|
|
|
这可能不是你的问题,但是如果在这是It1,后面的It2看起来不正确!你永远不会看到它高,因为你从来没有被打断的边缘,因为你正在改变一个错误的!
以上来自于百度翻译 以下为原文 It might not be your problem, but the INT2 in the follow does not look correct if this is INT1! EX_INT2_NegativeEdgeSet(); // PROGRAM FOR NEGATIVE TRIGGER EX_INT2_PositiveEdgeSet(); // program it for a rising edge interrupt You never see it high because you never get interrupted on that edge because you are changing the wrong one! |
|
|
|
只有小组成员才能发言,加入小组>>
5234 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3201 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
771浏览 1评论
659浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
588浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
670浏览 0评论
571浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 19:49 , Processed in 1.326801 second(s), Total 89, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号