完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
亲爱的同事们,我正在寻找一些修改微芯片DMA UART实例来运行在这个处理器上的建议。我不使用和声,因为我更喜欢使用以前的库,并建立在我现有的软件基础上。我最近决定,DMA UART对于减少一些中断驱动的应用程序的延迟是有用的,因为处理器负载可以被减少,并且有更多的时间可用于服务其他系统中断。通常,UART在系统工作时在用户终端上提供诊断和状态消息,所以我主要是在发送UART/DMA之后。我试图搜索这个论坛和其他来源的指导,但还没有成功地理解这个问题。我决定回到一个“已证实”的例子(Microchip UARTH回声),并建立起来。我把Microchip的例子转换为我的硬件上运行,但它只是坐在那里。我不想放弃,我想知道我做的不对,以确保我更好地掌握DMA引擎的使用。修改后的代码如下所示(系统不允许我上传文件),我相信它提供了足够的信息。让更多熟悉PIC32 MX这方面的人给我提意见(我非常感谢你的帮助)。当前,提示消息被正确显示,但是系统只是坐在那里,而不响应按键敲击(使用RealTealType)。这可能意味着中断没有正确工作,或者DMA信道(使用信道1)没有按要求设置。任何建议都是非常欢迎的。代码不长…旧的遗留函数中的一个(在下面的代码中指出)导致系统重新启动-不知道为什么。我删除了其他遗留函数,以防万一。我使用V1.40的C编译器,因为这是稳定的,我需要支持这个平台上的老系统。
以上来自于百度翻译 以下为原文 Dear Colleagues, I am looking for some advice in modifying the Microchip DMA UART example to run on this processor. I do not use HARMony, as I prefer to use the earlier libraries and to build on my existing base of software. I recently decided that a DMA UART would be useful to reduce latency in some interrupt driven applications, as the processor load can be reduced and more time be made available to service the other system interrupts. In general, the UART provides diagnostic and status messages on a user terminal while the system is working, so I am after a transmit UART/DMA mainly. I have tried to search this forum and other sources for guidance, but have not succeeded in understanding the problem. I decided to go back to a 'proven' example (microchip uart_echo), and to build up from that. I took the Microchip example and converted it to run on my hardware, but it just sits there. Rather than give up, I would like to understand what I am not doing correctly, to ensure that I have a better grasp on the use of the DMA engine. The modified code is shown below (the system would not allow me to upload a file for some reason), and I believe that it provides sufficient information to allow someone more familiar with this aspect of the PIC32MX to advise me (I would be very grateful for such assistance). Currently, the prompt message is displayed correctly, but the system then just sits there and does not respond to key strokes (using Realterm). This might imply that the interrupts are not working correctly, or that the DMA channel (using channel 1) is not set up as required. Any advice would be very welcome. The code is not long... One of the old legacy functions (noted in the code below) caused the system to reboot - not sure why. I removed the other legacy functions, just in case. I use V1.40 of the C compiler, as this is stable and I need to support older systems on this platform. /********************************************************************* * * DMA Uart echo example file * FileName: uart_echo.c * Dependencies: DmaApi.h * * Processor: PIC32MX * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * $Id: dma_api_example.c 4261 2007-08-22 16:32:28Z aura $ ********************************************************************/ #define _SUPPRESS_PLIB_WARNING 1 #define _DISABLE_OPENADC10_CONFIGPORT_WARNING 1 #define _DISABLE_OPENADC10_CONFIGSCAN_WARNING 1 //added for PIC32MX1xx #include #include #include // prototypes void DmaDoUartEchoExample(int pbClk); // some local data int DmaIntFlag; // flag used in interrupts // Configuration Bit settings // SYSCLK = 40 MHz (8MHz Crystal/ FPLLIDIV * FPLLMUL / FPLLODIV) // PBCLK = 20 MHz // Primary Osc w/PLL (XT+,HS+,EC+PLL) // WDT OFF // Other options are don't care #pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_2, FWDTEN = OFF #pragma config POSCMOD = XT, FNOSC = PRIPLL, FPBDIV = DIV_2 #define SYS_FREQ (40000000L) #define BAUDRATE 19200 // serial baudrate /********************************************************************* * Function: int main(void) * PreCondition: None * Input: None * Output: None * Side Effects: None * Overview: Examples for the usage of the DMA Peripheral Lib * Note: None. ********************************************************************/ int main(void) { int pbClk; // the PB frequency // Configure the device for maximum performance but do not change the PBDIV // Given the options, this function will change the flash wait states, RAM // wait state and enable prefetch cache but will not change the PBDIV. // The PBDIV value is already set via the pragma FPBDIV option above.. pbClk=SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE); // disable the JTAG port mJTAGPortEnable(0); PPSUnLock; // Allow PIN Mapping PPSOutput(1, RPA0, U1TX); // MAP UART1 Tx to PA0 PPSInput (3, U1RX, RPA4); // MAP UART1 Rx to PA4 PPSLock; // receive some data from the UART port and echo it back DmaDoUartEchoExample(pbClk); return 1; } /********************************************************************* * Function: void DmaDoUartEchoExample(int pbClk) * PreCondition: None * Input: pbClk - the PB frequency * Output: None * Side Effects: None * Overview: Examples for receiving some data from the UART and echoing it back using the DMA Peripheral Lib. * The received data is expected to end with a CR and has to be less than DmaGetMaxTxferSize() bytes in length. * We'll enable the DMA interrupts to signal us when the transfer is done. * Note: None. ********************************************************************/ void DmaDoUartEchoExample(int pbClk) { char dmaBuff[256+1]; // we'll store the received data here char tempchar; char buf[100]; int chn=1; // DMA channel to use for our example // NOTE: the ISR setting has to match the channel number //OpenUART1(UART_EN|UART_NO_PAR_8BIT|UART_1STOPBIT, UART_RX_ENABLE|UART_TX_ENABLE|UART_INT_TX_BUF_EMPTY|UART_INT_RX_CHAR, // pbClk/16/BAUDRATE-1); // selected baud rate, 8-N-1 //NB: BR calculation wrong again for 57600; reduced to 19200 for the moment // set hardware flow control UARTConfigure(UART1, UART_ENABLE_PINS_TX_RX_ONLY); // set baudrate UARTSetDataRate(UART1, SYS_FREQ/2.0, BAUDRATE); // set line control UARTSetLineControl(UART1, UART_DATA_SIZE_8_BITS|UART_PARITY_NONE|UART_STOP_BITS_1); // set FIFO mode UARTSetFifoMode(UART1, UART_INTERRUPT_ON_RX_NOT_EMPTY | UART_INTERRUPT_ON_TX_DONE); // enable peripheral, transmitter and receiver UARTEnable(UART1, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_TX | UART_RX)); // configure UART for TX/RX... INTSetVectorPriority(INT_VECTOR_UART(UART1), INT_PRIORITY_LEVEL_5); INTSetVectorSubPriority(INT_VECTOR_UART(UART1), INT_SUB_PRIORITY_LEVEL_1); sprintf(buf, "rnType up to 256 characters long string followed by Enter key; %urn", pbClk); putsUART1(buf); //displays correctly - pbClk is indeed 20 000 000 // configure the channel DmaChnOpen(chn, DMA_CHN_PRI2, DMA_OPEN_MATCH); DmaChnSetMatchPattern(chn, 'r'); // set r as ending character; retained to minimise changes // set the events: we want the UART1 rx interrupt to start our transfer // also we want to enable the pattern match: transfer stops upon detection of CR DmaChnSetEventControl(chn, DMA_EV_START_IRQ_EN|DMA_EV_MATCH_EN|DMA_EV_START_IRQ(_UART1_RX_IRQ)); //first one is different VJM //DmaChnSetEventControl(chn, DMA_EV_MATCH_EN|DMA_EV_START_IRQ(_UART1_RX_IRQ)); //first one is different VJM // set the transfer source and dest addresses, source and dest sizes and the cell size DmaChnSetTxfer(chn, (void*)&U1RXREG, dmaBuff, 1, 16, 1); //256 to 16 VJM DmaChnSetEvEnableFlags(chn, DMA_EV_BLOCK_DONE); // enable the transfer done interrupt: pattern match or all the characters transferred INTEnableSystemMultiVectoredInt(); // enable system wide multi vectored interrupts - move? INTSetVectorPriority(INT_VECTOR_DMA(DMA_CHANNEL1), INT_PRIORITY_LEVEL_5); INTSetVectorSubPriority(INT_VECTOR_DMA(DMA_CHANNEL1), INT_SUB_PRIORITY_LEVEL_3); //DmaChnSetIntPriority(chn, INT_PRIORITY_LEVEL_4, INT_SUB_PRIORITY_LEVEL_2); // set INT controller priorities CRASHES SYSTEM //THE LEGACY FUNCTION ABOVE SEEMS TO CRASH SYSTEM - NOT CLEAR WHY; USING INTset WORKS INTEnable(INT_SOURCE_DMA(DMA_CHANNEL1), INT_ENABLED); //DmaChnIntEnable(chn); // enable the chn interrupt in the INT controller DmaIntFlag=0; // clear the interrupt flag // enable the chn DmaChnEnable(chn); // let the user know that he has to enter a string // for example, you could do something like: //printf("rnType a string less than 256 characters followed by Enter key...Will echo it using the DMArnrn"); //putsUART1("rnInput here...rnrn"); // wait for the data to come in while(!DmaIntFlag); // just block here. In a real application you can do some other stuff while the DMA transfer is taking place // ok, we've received the data in the buffer putsUART1("rnReceived the character string. Now echoing it back...rnrn"); // now the TX part // reconfigure the channel DmaChnOpen(chn, DMA_CHN_PRI2, DMA_OPEN_MATCH); // set the events: now the start event is the UART tx being empty // we maintain the pattern match mode DmaChnSetEventControl(chn, DMA_EV_START_IRQ_EN|DMA_EV_MATCH_EN|DMA_EV_START_IRQ(_UART1_TX_IRQ)); // set the transfer source and dest addresses, source and dest size and cell size DmaChnSetTxfer(chn, dmaBuff, (void*)&U1TXREG, 256, 1, 1); DmaIntFlag=0; // clear the interrupt flag DmaChnStartTxfer(chn, DMA_WAIT_NOT, 0); // force the DMA transfer: the UART2 tx flag it's already been active // wait for data to be output while(!DmaIntFlag); // just block here // DMA Echo is complete DmaChnIntDisable(chn); // disable further interrupts from the DMA controller putsUART1("rnEcho back completed...rnrn"); } // handler for the DMA channel 1 interrupt //void __ISR(_DMA1_VECTOR, ipl5) DmaHandler1(void) void __ISR(_DMA1_VECTOR, IPL5AUTO) DmaHandler1(void) { int evFlags; // event flags when getting the interrupt //mDmaChnClrIntFlag(1); // original code used this legacy function evFlags=DmaChnGetEvFlags(1); // get the event flags DmaIntFlag=1; if(evFlags&DMA_EV_BLOCK_DONE) { // just a sanity check. we enabled just the DMA_EV_BLOCK_DONE transfer done interrupt DmaIntFlag=1; DmaChnClrEvFlags(1, DMA_EV_BLOCK_DONE); } // clear interrupt flag INTClearFlag(INT_SOURCE_DMA(1) ); //replacement flag clear... } Many thanks in anticipation. VJM |
|
相关推荐
9个回答
|
|
我怀疑问题可能是我没有对齐UART和DMA之间的中断优先级,但是我不清楚如何做到这一点…(它是自动的,不管主处理机中断优先级如何)我认为DMA ISR是可以的,我不真正理解DMA是如何处理UART中断的,而不是DmaChnSetEventControl上的链路。欢迎所有的建议。关于检查手册。再一次。。。
以上来自于百度翻译 以下为原文 I suspect the problem may be that I have not aligned the interrupt priorities between the UART and the DMA, but I am not clear on how to do this... (is it automatic, regardless of main processor interrupt priorities?) I think that the DMA ISR is OK; I do not really understand how the DMA handles the UART interrupt, other than the link that is made in DmaChnSetEventControl. All advice welcome. About to check the manuals. Again... |
|
|
|
另一个问题,恐怕。原始代码不能启用UART中断,即:-OpenUART1(UARTAGEN)UARTZONNOPARY8PAR8,UARTHAR1STOBIT,UARTHARTITIN TXBUFIUN空UTARTIN IN RXYCHAR,PBCK/16 / BaDATRE-1);/ /选择波特率,8NNI混淆了我;我启用了UFART中断,使用FIFO库函数。以前我已经将代码修改为:OpenUART1(UARTAGEN)UARTZONIOPARY8PARY8UTURS1SCOBIT,UARTHARXRXIN使能UARTHARTXII使能UARTHARTIN TIXBUFIZULL UUARTIN IN RXYCHAR,PBCK/16/BaDATRE-1);/ /选择波特率,8N-1-这没有区别。问题是UART中断是否需要在UART中设置合适的位之前触发,以触发DMA响应——是这样吗?该示例将建议在任何情况下设置该位,并且中断不需要被具体地启用。
以上来自于百度翻译 以下为原文 Another question, I'm afraid. The original code did not enable the UART interrupts i.e. it was:- OpenUART1(UART_EN|UART_NO_PAR_8BIT|UART_1STOPBIT, UART_INT_TX_BUF_EMPTY|UART_INT_RX_CHAR, pbClk/16/BAUDRATE-1); // selected baud rate, 8-N This confused me; I enabled the UART interrupts in my code, using the FIFO library function. I had previously modified the code to: OpenUART1(UART_EN|UART_NO_PAR_8BIT|UART_1STOPBIT, UART_RX_ENABLE|UART_TX_ENABLE|UART_INT_TX_BUF_EMPTY|UART_INT_RX_CHAR, pbClk/16/BAUDRATE-1); // selected baud rate, 8-N-1 This made no difference. The question is whether UART interrupts need to be enabled before the appropriate bit is set in the UART to trigger the DMA response - is this the case? The example would suggest that this bit is set in any case, and that the interrupts do not need to be specifically enabled. |
|
|
|
嗨,我没有尝试过很多,所以不能发现需要什么使它工作。围绕中断启用的术语是不清楚的,中断使能通常意味着当中断标志被外围设置时,中断控制器可以中断CPU。对于UART,有控制位设置。在数据表中引起中断标志的事件,这些被称为“中断模式选择”位,而不是在PLIB设置中的UART启用。当使用DMA时,我认为应该选择这些,以便为发送或接收的每个字节设置中断标志,这意味着:UXSTATITITS.UTXISEL =0;以及:UxStestIt.UrxSele= 0;这与重置默认值相同,因此不需要设置。UART中断不需要启用。中断启用是中断控制器的一个属性,无论在接收或传输字符时CPU是否中断。当DMA被期望处理传输时,这不是你想要发生的。同样地,中断优先级和中断控制器和CPU之间的关系,CPU是否应该被中断,或者当另一个中断已经活动时,CPU是否中断,DMA控制器使用中断。从UART发出的标志信号启动下一个传输。我在任何地方都没有找到一个很好的描述,这个信令实际上是如何运作的,似乎中断标志寄存器不参与其中。迈西尔
以上来自于百度翻译 以下为原文 Hi, I have not tried much of this, so cannot spot what will be needed to make it work. Terminology around interrupt enable is unclear, Interrupt enable usually means enabling Interrupt controller to interrupt the CPU when a interrupt flag is Set by a peripheral. For UART, there are control bits to set what events to cause interrupt Flag to be raised, in datasheet, these are called 'Interrupt Mode Selection' bits, Not UART Enable as in Plib settings. When DMA is used, I think these shall be selected such that interrupt Flag is set for every byte transmitted or received, meaning: UxSTAbits.UTXISEL = 0; and: UxSTAbits.URXISEL = 0; This is the same as reset default, so shouldn't need setting. UART interrupts should Not need to be enabled. Interrupt Enable is a property of the Interrupt controller, whether the CPU shall be interrupted when a character have been received or transmitted. This is exactly Not what you want to happen, when DMA is expected to handle the transfer. Same with Interrupt Priority, that is also a matter between Interrupt Controller and CPU, whether the CPU shall be interrupted, or not, when another interrupt is already active. DMA controller use the Interrupt Flag signal from UART to initiate the next transfer. I have not found a good description anywhere, of how this signaling actually function, it seem that Interrupt Flag Register is Not involved in this. Mysil |
|
|
|
亲爱的Mysil,谢谢你的注意。你的评论很有说服力,并与我所做的额外阅读联系在一起。它也与原始代码相吻合,这显然没有启用UART中断。我会检查这是否有任何区别,但我认为我已经尝试过没有UART中断的代码,但没有成功。我必须做一些明显的错误,我只是看不见。最好的祝愿,VJM
以上来自于百度翻译 以下为原文 Dear Mysil, Thank you for your note. Your comments make sense, and tie up with the additional reading that I have done. It also tallies with the original code, which explicitly did not enable the UART interrupts. I will check to see if this makes any difference, but I think that I have already tried the code without the UART interrupts, and was not successful. I must be doing something obviously wrong; I just cannot see it. Best wishes, VJM |
|
|
|
亲爱的Mysil,我已经删除了FIFO中断设置,但没什么区别。代码仍然显示提示(和PBCK的值),并且不对键盘作出响应。更改是注释该行;我认为这足以证明点://SET FIFO模式//UARTSetFifoMode(UART1,UARTHYBASTTHONTRON ORXXNOTHOPENUTY UARTHYBASECTORION TXXON);感谢周围的人、发送者和接收者,谢谢你的建议;不幸的是,仍然在挣扎!最美好的祝愿,VJM
以上来自于百度翻译 以下为原文 Dear Mysil, I have removed the FIFO interrupt setting, but it made no difference. The code still displays the prompt (and the value of pbClk), and does not respond to the keyboard. The change was to comment out the line; I think that this is sufficient to prove the point: // set FIFO mode //UARTSetFifoMode(UART1, UART_INTERRUPT_ON_RX_NOT_EMPTY | UART_INTERRUPT_ON_TX_DONE); // enable peripheral, transmitter and receiver Thanks for the suggestion; still struggling, unfortunately! Best wishes, VJM |
|
|
|
嗨,我想你首先应该有一个例子,它使用中断,然后移动到DMA。一些例子:http://www. EC.Euu/Lunt/CursSe/ECe47 60/PIC32/PLBIIAppPLES/PLBYEXPLUES/http://SuroSurfGe.NET/PrimeSt/PIC32 UART传输DMA/问候
以上来自于百度翻译 以下为原文 Hi, I would say you should first have an example which runs using interrupts and then move to DMA. Some examples : https://people.ece.cornell.edu/land/courses/ece4760/PIC32/PLIB_examples/plib_examples/ https://sourceforge.net/projects/pic32uarttransmissionusingdma/ Regards |
|
|
|
嗨,你在运行优化吗?变量:dMnTrand应该被声明为MySysEdv:Actudio:附件是我的版本:UARTHARECHORE示例。已经在PIC32 MX250F128B上使用UART2映射到RB10和RB11上。它与C32 V2.02和XC32 V1.34一起发送38400位/s到一个PIDIT 2 UART工具。再试一次MPLAB X和XC32。迈西尔
以上来自于百度翻译 以下为原文 Hi, Are you running with optimization? The variable: DmaIntFlag should be declared volatile // some local data volatile int DmaIntFlag; // flag used in interrupts Mysil Edit: Works for me. Attached is my version of the: uart_echo example. Have tried it on PIC32MX250F128B using UART2 mapped to RB10 and RB11. Works with C32 v2.02 and XC32 v1.34 sending 38400 bit/s to a PICkit 2 UART tool. Project is MPLAB 8.92 Maybe trying MPLAB X and XC32 another day. Mysil Attachment(s) uart_echo.zip (11.14 KB) - downloaded 52 times |
|
|
|
亲爱的RISC和MysIL,我对延迟反应的道歉——时区的差异部分归咎于我,我怀疑!我已经中断了在其他领域的工作,一般来说,所以我认为我有一个PIC32的操作这方面的合理把握,但这是一个有趣的一点。我当然会审查您提供的参考资料。是的,我正在运行优化,恐怕我没有想到这个方面,恐怕。我将重新编译,没有优化,以及纠正你指出这个变量作为“易失性”的优秀点。这是一个很好的捕捉!像往常一样,问题假设——在这种情况下,代码是“好”的,并且覆盖了所有的情况。我将运行在我的自定义硬件上提供的代码MysIL,看看我是否能复制他的成功(适当修改以适应我使用的引脚上的UART1)。如您所知,我使用XC32 V1.40(通常是O2),以及最新的MPLAB X。我也已经打算回到真正的基础上,并且在内存传输中尽可能简单地让DMA在内存中运行,以确保我理解这个引擎的运行。我非常感谢您的建议和支持。再次感谢。我将在今天晚些时候报告。祝你好运,VJM
以上来自于百度翻译 以下为原文 Dear RISC and Mysil, Apologies for the delay in responding - time zone differences partly to blame, I suspect! I have interrupts working well in other areas, in general, so I think that I have a reasonable grasp of this aspect of the PIC32's operation, but it is an interesting point. I will certainly review the references you were kind enough to provide. Yes, I am running with optimisation; I had not thought about this aspect, I'm afraid. I will re-compile with no optimisations, as well as correcting the excellent point you make about declaring this variable as 'volatile'. This is a good catch! As always, question assumptions - in this case that the code was 'fine' and covered all cases. I will run the code Mysil provided on my custom hardware to see if I can duplicate his success (suitably modified to suit UART1 on the pins I use). As you know, I use XC32 v1.40 (typically with o2), and the latest MPLAB X. I also already intended to go back to real basics and get DMA running internally in memory transfers as simply as possible to ensure that I understood the operation of this engine. I really appreciate your advice and support - many thanks again. I will report back later today. Best wishes, VJM |
|
|
|
亲爱的同事,为延迟道歉-我被锁在外面,尽管多次尝试要求密码重置-只是刚刚清除!建议的变化没有区别,而且“好”的代码在我的系统上没有运行在UART1上。然后我更深入地挖掘,并且意识到UART上的“数据接收”位没有按照预期设置,尽管在合适的PIC32引脚上出现了良好的信号。这表明问题是在系统设置中,而不是在DMA UART代码本身中。然后我输入了我的“标准”PIC32×PrimMA指令来设置设备,嘿!我附上下面两个版本的信息。/---------------*/*-Pracm配置,FPLLIdIV= DIVIO2O* PrimaMac配置文件FPLLoDIV= DIVIZ2//是DIVIO1PARMA配置,FPLLMUL= MULL2020,PracMA配置FFDTEN= OF//开机,用于生产一个配置WTTPS=PS131072//初始设置为4秒;参见Microchip文档,即:TraceMang-COMFIG配置FFSCONEN=O//需要启用RTC二级振荡器α-PrimaMac配置,ICESL=ICSYPGX2//在ISS 2板上改变/ /下设置不工作/ ** PrimaMatlab配置FPLLMUL= Mule20,FPLLIdIV= DIVIZ2,FPLLoDIV= DIVIZ2,FWDTEN=OX-PARMMA配置PASCMOD=XT,FNOSc= PrPLL,FPBDIV= DIVI2*/CODEI将建议文档在这方面有点有限,并且我使用的PIN(RA4或PIN 12)冲突。我知道有必要清除用于数字输入的引脚的模拟设置(在我的情况下,所有引脚),因此安塞拉已经设置为0。问题的最有可能的原因是SoSO,以及相关联的Apple TracMA指令(FsOsCon=OFF)来关闭这个问题。当然,这不会影响UART2,它将与原UART的正确操作结合在一起。我可能错了,我很感激证实这一结论。吸取的教训是:1。DMA UART不需要在UART上启用中断——事实上,如果它们是…2,它可能是不稳定的。如果你改变了设备或外围设备的数量,不要假设在任何微芯片的例子中都是合适的。在较小的设备上对引脚进行冲突的功能分配的双重检查;在我的例子中,我相信次级振荡器冲突,这在文档中是不清楚的(请确认!)4。对提供的代码有信心,但检查和检查再次…道歉,如果我陈述众所周知的点,但我相信,共享的经验总是有价值的!再次感谢你们的支持,VJM
以上来自于百度翻译 以下为原文 Dear Colleagues, Apologies for the delay - I was locked out despite several attempts at requesting a password reset - only just cleared! The suggested changes made no difference, and the 'good' code did not run on UART1 on my system. I then dug more deeply, and realised that the 'data received' bit on the UART was not being set as expected, despite good signals appearing on the appropriate PIC32 pin. This suggested that the problem was in the system setup, rather than in the DMA UART code itself, perhaps. I then imported my 'standard' PIC32 #pragma directives to set up the device and, hey presto, it worked! I attach the two versions below for information. code /**-------------------------- PIC32 configuration ----------------------------*/ #pragma config FPLLIDIV = DIV_2 #pragma config FPLLODIV = DIV_2 //was DIV_1 #pragma config FPLLMUL = MUL_20 #pragma config FWDTEN = OFF //switch on for production #pragma config WDTPS = PS131072 //set to 4 seconds initially; see microchip documentation #pragma config FCKSM = CSDCMD #pragma config FPBDIV = DIV_2 #pragma config OSCIOFNC = OFF #pragma config POSCMOD = XT #pragma config IESO = OFF #pragma config FNOSC = PRIPLL #pragma config CP = OFF #pragma config PWP = OFF #pragma config BWP = OFF #pragma config FSOSCEN = OFF //need to enable for RTC secondary oscillator #pragma config ICESEL = ICS_PGx2 //changed on Iss 2 board //the settings below did NOT work /*#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_2, FWDTEN = OFF #pragma config POSCMOD = XT, FNOSC = PRIPLL, FPBDIV = DIV_2 */ code I would suggest that the documentation is a little limited in this area and that the pin (RA4, or pin 12 on the package that I am using) was conflicted. I am aware of the need to clear the analogue settings for pins that are used as digital inputs (all pins, in my case), so ANSELA was set to 0 already. The most likely cause of the problem is SOSCO, and the associated #pragma directive (FSOSCEN = OFF) to switch this off. This would, of course, not affect UART2, which would tie in with the correct operation on this UART with the original #pragma directives. I may be wrong, and I would be grateful for confirmation of this deduction. Lessons learnt: 1. DMA UART does NOT need interrupts on the UART to be enabled - in fact, it can be erratic if they are... 2. Make no assumptions that the #pragma directives are appropriate in any microchip example if you change device or peripheral number; if in doubt, use proven ones that have been derived separately 3. Double check for conflicting function allocation on pins in smaller devices; in my case I believe that the secondary oscillator conflicted, which is not clear in the documentation (please confirm!) 4. Have confidence in code that is supplied, but check and check again... Apologies if I am stating well known points, but I believe that shared experience is always valuable! Thanks again for your support, VJM |
|
|
|
只有小组成员才能发言,加入小组>>
5204 浏览 9 评论
2016 浏览 8 评论
1942 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3188 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2244 浏览 5 评论
755浏览 1评论
641浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
550浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
654浏览 0评论
554浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-5 12:17 , Processed in 1.496741 second(s), Total 93, Slave 76 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号