完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我在EUSAT和MCC上遇到了一些问题。我的第一个问题是我不能把一个字符串从PIC发送到PC。我能做的就是发送一个字符。我的代码是在while(1)& gt;;如果(EuSART1O1DATAARDATY),我用UART1IL EsCREBIR打印两个东西:填充的数组,我在读取,一个数组i在初始化时初始化,填充的数组我在终端中看到它(我使用RealEngess),但是我初始化的那个我没有。我看不出来。我不知道发生了什么,我也想用中断来获取数据。在MikroC,我所做的是:我想在MPLAB中做类似的事情,但是我不知道如何将这个添加到MCC的代码中。或者如何使用MCC编写的代码来像MikROC代码那样运行。每隔一定时间,我会收到大约1000个字符。我使用PIC18F47 K40,MPLAB V4.15和MCC V3.45.1。
以上来自于百度翻译 以下为原文 Hello all, I'm having some problems with the eusart and mcc. My first problem is I can't send a string from the PIC to the PC. What I can do is send a single character. My code is #include "mcc_generated_files/mcc.h" uint16_t count = 0; uint16_t count2 = 0; uint8_t i = 0; char data[10]; char array[] = "Hello World"; char string[5] = {0x31,0x32,0x33,0x34,0x00}; void TMR0_Function(); void TMR1_Function(); void Uart1_Escribir(char *_cadena); void main(void) { // Initialize the device SYSTEM_Initialize(); TMR0_SetInterruptHandler(TMR0_Function); TMR1_SetInterruptHandler(TMR1_Function); // Enable the Global Interrupts INTERRUPT_GlobalInterruptEnable(); // Enable the Peripheral Interrupts INTERRUPT_PeripheralInterruptEnable(); while (1) { // Add your application code /*Uart1_Escribir(string); printf("%sn", array); // Doesn't matter if I try to print with printf or Uart1_Escribir or both I don't see anything in the terminal EUSART1_Write('a'); LED_ROJO_Toggle(); __delay_ms(500);*/ if (EUSART1_DataReady) { for (i = 0 ; i < 8 ; i++) { data = EUSART1_Read(); if (data == '+') break; } data = 0; Uart1_Escribir(string); // I don't see it in the terminal Uart1_Escribir(data); // I see it in the terminal } } } void TMR0_Function() { count++; if (count >= 250) { count = 0; LED_VERDE_Toggle(); } } void TMR1_Function() { count2++; if (count2 >= 5000) { count2 = 0; //LED_ROJO_Toggle(); } } void Uart1_Escribir(char *_cadena) { /*int j = 0; for (j = 0; j < strlen(_cadena); j++) { EUSART1_Write(_cadena[j]); }*/ while (*_cadena) { EUSART1_Write(*_cadena++); } } Inside the while(1) >> if (EUSART1_DataReady) I'm printing with the Uart1_Escribir two things the array that is fill with I'm reading and a array I initialized in the beginning, the array that is filled I see it in the terminal (I use RealTerm) but the one that I initialized I don't see it. I don't know what is happening. Also I want to use the interrupt to get data. In MikroC what I did was: void interrupt() { if (PIR3.RC1IF) { char byte = UART1_Read(); array[index] = byte; index++; if (index == characters_wanted) { // Or byte == final_character do something... } } } I want to do somthing similar in mplab but I don't know how to add this to code made by the mcc. Or how to use the code made by the mcc to behave like the mikroc code did. I will receive around 1000 characters every certain time. I use PIC18F47k40, MPLAB v4.15 and MCC v3.45.1 |
|
相关推荐
6个回答
|
|
K40设备有一个导致这个问题的bug。这是你读过的勘误表,对吧?勘误表和数据表一样重要。在任何情况下,您都需要通过在编译器的“附加选项”项目属性中输入勘误表NVMReg来打开勘误表。
以上来自于百度翻译 以下为原文 The K40 devices have a bug that causes this. It's in the errata which you have read, right? The errata is as important as the datasheet. In any case you need to turn on the errata workaround by entering --ERRATA NVMREG I think in the "Additional Options" project properties for compiler |
|
|
|
不,我没有看过勘误表。在您的帮助下,这篇文章HTTP://www. McCHIP.COM/FUMMS/M969418.ASPX可以用我的函数和PrTrF正确打印。谢谢。现在关于接收中断,我如何将我的代码添加到MCC生成的代码中?
以上来自于百度翻译 以下为原文 No, I didn't read the errata. With your help and this post http://www.microchip.com/forums/m969418.aspx I could print correctly with my function and with printf. Thanks. Now about the receive interrupt, how can I add my code to the one that was generated by mcc? |
|
|
|
MCC是一个代码生成器。它生成基础知识,然后将自己的代码添加到生成的代码中。
以上来自于百度翻译 以下为原文 MCC is a code generator. It generates the basics, then you add your own code to what it generated. |
|
|
|
谢谢,但是我仍然不知道我可以在哪里添加我的代码,我不太明白循环缓冲区是如何工作的。我不知道我是否必须修改EasART1xReaveVISR或者做其他的函数,并从中断中断管理器调用它。
以上来自于百度翻译 以下为原文 qhb, thanks, but still I can't figure out where I can add my code and I don't understand quite well how the circular buffer works. I don't know if I have to modify the EUSART1_Receive_ISR or make a other function and call it from INTERRUPT_InterruptManager |
|
|
|
检查这个线程。我试图解释清楚。http://www. McCys.com /论坛/ M1035431.ASPX第1035438。
以上来自于百度翻译 以下为原文 Check this thread. I tried to explain it clearly. http://www.microchip.com/forums/m1035431.aspx#1035438 |
|
|
|
您不必触摸任何MCC生成的UART代码。只需使用读写函数来接收/发送添加到main()中的代码(或者从main调用的函数)
以上来自于百度翻译 以下为原文 You shouldn't have to touch any MCC generated uart code. Just use the read and write functions to receive/send in the code you add to main() (or whatever function you call from main) |
|
|
|
只有小组成员才能发言,加入小组>>
5163 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
733浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
505浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 21:06 , Processed in 1.254853 second(s), Total 89, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号