[PIC®/AVR®/dsPIC®产品] IO模拟I2C

[复制链接]
3392|8
 楼主| zhuomuniao110 发表于 2023-10-21 15:57 | 显示全部楼层 |阅读模式
PIC的MCC配置的I2C,根本没法用,不知道是我不会用还是这个软件生成的有问题,生成的库函数也没说明,根据意思使用,结果怎么弄都不对。。。跑不起来。
换成IO模拟一次搞定
先配置为输出

再设置IO口特性,根据选择起个名字,方便后面使用


完善IO操作的映射关系

然后就可以直接使用OLED的操作函数了

  1. #include "mcc_generated_files/system/system.h"
  2. #include "oled/oled.h"
  3. #include "oled/oledpic.h"
  4. /*
  5.     Main application
  6. */

  7. int main(void)
  8. {
  9.     float numberfu=12.5;
  10.     SYSTEM_Initialize();

  11.     // If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
  12.     // If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global Interrupts
  13.     // Use the following macros to:

  14.     // Enable the Global Interrupts
  15.     INTERRUPT_GlobalInterruptEnable();

  16.     // Disable the Global Interrupts
  17.     //INTERRUPT_GlobalInterruptDisable();
  18.     OLED_Init();
  19.     OLED_Allfill();
  20.     OLED_Clear();
  21.     OLED_ShowPic(90,0,122,4,BMP1);
  22.     OLED_ShowHzbig(0,0,0);
  23.         OLED_ShowStr(33,0,"Hello",16);
  24.         HAL_Delay(1000);
  25.         OLED_Clear();

  26.         OLED_ShowFloat(50,0,numberfu,3,16);
  27.         OLED_ShowHanzi(50,2,0);
  28.         OLED_ShowHanzi(34,2,1);
  29.             for(uint32_t number=500;number<600;number++)
  30.         {
  31.                 OLED_ShowNum(80,2,number,4,16);
  32.                 HAL_Delay(10);
  33.         }
  34.         OLED_ShowChar(4,0,'H',16);
  35.         OLED_ShowChar(4,2,'M',16);
  36.         HAL_Delay(2100);
  37.     while(1)
  38.     {
  39.     }   
  40. }
下载测试,一次点亮。
谁知道那个MCC配置的如何用啊,看了好多贴,都说不能用。。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
 楼主| zhuomuniao110 发表于 2023-10-21 15:58 | 显示全部楼层
厂家也不赶紧看看是哪儿的问题。
 楼主| zhuomuniao110 发表于 2023-10-21 15:58 | 显示全部楼层
厂家参靠一下其他厂家的代码怎么写吧,哎,受不了。
ayb_ice 发表于 2023-11-6 13:21 | 显示全部楼层
我从来不用硬件的IIC,SPI,不管什么MCU
Bowclad 发表于 2023-11-9 19:43 | 显示全部楼层
ayb_ice 发表于 2023-11-6 13:21
我从来不用硬件的IIC,SPI,不管什么MCU

硬件SPI的速度提升巨大啊
Undshing 发表于 2023-11-12 18:27 | 显示全部楼层
模拟的比较好移植
Henryko 发表于 2023-11-14 11:16 来自手机 | 显示全部楼层
模拟的速度上不去啊
Jacquetry 发表于 2023-11-20 10:42 来自手机 | 显示全部楼层
这个方便移植
AloneKaven 发表于 2023-11-21 09:31 来自手机 | 显示全部楼层
硬件速度快,软件方便移植
您需要登录后才可以回帖 登录 | 注册

本版积分规则

233

主题

3529

帖子

11

粉丝
快速回复 在线客服 返回列表 返回顶部