完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛扫一扫,分享给好友
|
嗨,我对PIC完全陌生,但是我已经冒了险,用PIC18F97J60 100引脚MCU设计了新设备,主要是因为它的以太网控制器和“语音”告诉我PIC有很多资源、例子等等。现在该让它活跃起来了,我注意到我遇到了麻烦。我第一个遗憾的惊讶是plib被正式中断了(我使用MPLAB X+XC8),而且MCC还不支持这个MCU:-/所以正式地,我独自一人没有库……但是我没有足够的时间来完成这个项目来从头开始编写所有内容,即使外围设备看起来不是很复杂。所以我发现了PLIB的存档并安装在XC8文件夹中,但是当然存在定义的问题。我现在不记得了,就像在某处所描述的…所以,我已经安装了XC8 v1.31,其中包含plib,并且编译正确。因此,在这里,我使用了MPLAB X+XC8 v1.31+plib,但是仍然没有很好的示例,即中断驱动的UART(使用FIFO)。在DOCS/MPLABOXXC8IUTURARALL图书馆中,PDF只有简单的轮询示例。另一方面,我发现了有人使用plib中的OpenUART()的示例,但是之后在配置在OpenUART()中的寄存器中手动设置位,所以我怀疑它是一个好例子。在发送任何字符后,我的LED(在主环中定义的time0 Tik+模式)是冻结的,所以我认为ISR有问题。现在,我在MCU数据表中看到,当读取RCREG1时,RC1IF标志被清除,但是在前面提到的例子中,有人试图写入PIR1bits.RC1IF=0;:-/最后,我需要以太网(时间同步+串行通信)、ADC、GPIO、SPI、I2C和定时器。有什么好的资源吗?感谢您的帮助!:)
以上来自于百度翻译 以下为原文 Hi, I'm absolutely new to PIC but I have taken risk and designed new device with PIC18F97J60 100-pin MCU, mainly because of its Ethernet controller and "voices" telling me that PICs have many resources, examples etc. Now it's time to make it alive and I've noticed that I've got into trouble. My first sad surprise was that plib is of officially discontinued (I use MPLAB X + XC8) and MCC doesn't support this MCU yet :-/ So officially I stand alone without libraries... But I don't have enough time with this project to write everything from scratch, even if peripherals doesn't seem to be very complicated. So I have found archive of plib and installed it in XC8 folder but of course there is a problem with definitions (of INTCONbits? I don't remember now), like described somewhere... So I have installed XC8 v1.31 with plib included and it compiles correctly. So here I am, with MPLAB X + XC8v1.31 + plib, but still without good examples i.e. for interrupt driven UART (with FIFO). In docs/MPLAB_XC8_Peripheral_Libraries.pdf there is only simple example with polling. On the other hand I have found example where someone uses OpenUART() from plib but after that manually sets bits in registers that are configured in OpenUART() so I doubt it's a good example. I was trying to implement it quickly but unfortunately without luck. After sending any char my LED (timer0 ticks + pattern defined in main loop) was freezing so I assume something is wrong with ISR. Now I see in MCU datasheet that RC1IF flag is cleared when RCREG1 is read but in mentioned example someone tries to write PIR1bits.RC1IF = 0; :-/ Finally I will need Ethernet (time sync + serial communication), ADC, GPIO, SPI, I2C and timers. Are there any GOOD resources for that? :) Any help appreciated! :) |
|
相关推荐
4个回答
|
|
|
MCU是否需要额外的“魔法”来激活USAT?我不知道这是否重要,但是我在MPLLABX中打开了sourcepic18plibUSART1open.c文件,并且没有定义“EAUSART_Vx”,所以一切都是灰色的(非活动的)。当我使用Open1USAT()函数时,我想知道是否有关联。但是我已经复制并改写了一个版本的代码到我的.c,步进式调试器,以确保它被执行并且没有任何…每秒钟调用一个字母7AuthART(a)似乎不起作用。我有一个UART / USB转换器,它闪烁着红色LED当我发送个人电脑和绿色LED时,MCU响应。不幸的是,只能看到红色的LED。
以上来自于百度翻译 以下为原文 Is there any additional "magic" needed in that MCU to activate USART? I don't know if it matters but I have opened sourcespic18plibUSARTu1open.c file in MPLAB X and none of "EAUSART_Vx" was defined so everything was grey (inactive). I wonder if anything is linked when I use Open1USART() function. But I have copied and renamed code of one version to my main.c, stepped into Open7USART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_BRGH_HIGH & USART_ADDEN_OFF & USART_CONT_RX, 162); //9600@25MHz in debugger to be sure it's executed and nothing... Write7USART('a') called every second doesn't seem to work. I have an UART/USB converter and it blinks with red LED when I send somenthing from PC and with green LED when MCU responds. Unfortunately only red LED can be seen. void Open7USART( unsigned char config, unsigned int spbrg) { TXSTA1 = 0; // Reset USART registers to POR state RCSTA1 = 0; if(config&0x01) // Sync or async operation TXSTA1bits.SYNC = 1; if(config&0x02) // 8- or 9-bit mode { TXSTA1bits.TX9 = 1; RCSTA1bits.RX9 = 1; } if(config&0x04) // Master or Slave (sync only) TXSTA1bits.CSRC = 1; if(config&0x08) // Continuous or single reception RCSTA1bits.CREN = 1; else RCSTA1bits.SREN = 1; if(config&0x10) // Baud rate select (asychronous mode only) TXSTA1bits.BRGH = 1; if(config&0x20) // Address Detect Enable RCSTA1bits.ADDEN = 1; if(config&0x40) // Interrupt on receipt PIE1bits.RC1IE = 1; else PIE1bits.RC1IE = 0; if(config&0x80) // Interrupt on transmission PIE1bits.TX1IE = 1; else PIE1bits.TX1IE = 0; SPBRG1 = spbrg; // Write baudrate to SPBRG1 SPBRGH1 = spbrg >> 8; // For 16-bit baud rate generation TXSTA1bits.TXEN = 1; // Enable transmitter RCSTA1bits.SPEN = 1; // Enable receiver TRISCbits.TRISC6 = 0; TRISCbits.TRISC7 = 1; if(TXSTA1bits.SYNC && !TXSTA1bits.CSRC) //synchronous slave mode TRISCbits.TRISC6 = 1; } void Write7USART(char data) { if(TXSTA1bits.TX9) // 9-bit mode? { TXSTA1bits.TX9D = 0; // Set the TX9D bit according to the if(USART1_Status.TX_NINE) // USART1 Tx 9th bit in status reg TXSTA1bits.TX9D = 1; } TXREG1 = data; // Write the data byte to the USART1 } |
|
|
|
|
|
好吧,我在自言自语,但是我再向前一步。新的,闪亮的一天已经来到,我的DSO波形出现在TX线上。因为默认情况下我使用了AND掩码,所以在baud1UART()中漏掉了一些参数,所以波形被反转了,但是经过快速调整,现在可以了,我每秒都得到“a”。在哪里可以找到像“voidinter.SerialRxPinInter.()”这样的描述?在前面提到的示例代码中,但是现在它似乎没有被调用,并且在字符接收之后设备冻结,所以我猜ISR应该被不同地调用(?)编辑:我已经在数据表中挖掘过,我发现这个名字“无效中断SerialRxPin中断())是误导性的。在另一个例子中,我已经“空中断Time0OffFuffE()”,但是在这个MCU中没有单独的ISR。对于高优先级和低优先级中断,可以使用一个通用或两个。我的设备被冻结了,因为在第一个可用的中断例程(Timer0Overflow)中,没有RX中断标志检查和清除……顺便说一下,我刚才注意到上拉开关被切换为所有端口引脚(不是单个的),并且不是所有端口都有它们。嗯…- -
以上来自于百度翻译 以下为原文 Ok, I'm talking to myself ;) But I'm one step further. New, shiny day has come and on my DSO waveforms appeared on TX line. Because by default I use AND masks I have missed some parameters in baud1UART() so waveforms were inverted but after quick tweaking it's OK now and I get 'a' every second. Where things like description of "void interrupt SerialRxPinInterrupt()" can be found? It was in mentioned earlier example code but now it doesn't seem to be called and device freezes after character receiving so I guess ISR should be called differently(?). EDIT: I have digged in datasheet and I've found that this name "void interrupt SerialRxPinInterrupt()" was misleading. I had already "void interrupt Timer0Overflow()" from another example but there are no separate ISRs in this MCU. You can have one general or two - for high and low priority interrupts. My device was freezing because in first available interrupt routine (Timer0Overflow) there was no RX interrupt flag checking and clearing... BTW I have just noticed that pull-ups are switched for all port pins (not individually) and not all ports have them.. argh.. :-/ |
|
|
|
|
|
你好,德摩克,我们会帮你的忙。抱歉耽搁了。戴维OtnPIC18应用经理
以上来自于百度翻译 以下为原文 Hello demmoc, We'll get you some help. Sorry for the delay. David Otten PIC18 Applications Manager |
|
|
|
|
|
我觉得你已经解决了很多问题,如果不是全部的话。你还需要帮助吗?顺便说一下,RXIF和TXIF标志是只读的。当RX输入缓冲器中有未读数据时,RXIF标志被设置。当缓冲区为空时,读取RXREG将清除RXIF标志。当TXREG可以接受字符进行传输时,设置TXIF标志。TXIF只有在输出移位寄存器正忙于处理一个字符并且TXREG中正在挂起另一个用于传输的字符时才是清晰的。只有当发送的字符没有被写入TXRG时,才启用TX中断。当没有更多的数据要发送时禁用TXEY。
以上来自于百度翻译 以下为原文 demmoc: I appears that you have figured out many, if not all, your issues. Do you still need help? By the way, the RXIF and TXIF flags are read-only. The RXIF flag is set when there is unread data in the RX input buffer. Reading the RXREG will clear the RXIF flag when the buffer is empty. The TXIF flag is set when the TXREG can accept a character for transmission. TXIF is only clear when the output shift register is busy with a character and another character for transmission is pending in the TXREG. TX interrupts should only be enabled when characters to be sent have not been written to the TXREG. Disable TXIE when no more data remains to be sent. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
485 浏览 0 评论
5806 浏览 9 评论
2346 浏览 8 评论
2234 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3540 浏览 3 评论
1145浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1114浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
882浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
487浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-9 02:27 , Processed in 0.853394 second(s), Total 77, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1515