Other Parts Discussed in Thread: SYSCONFIG,
在SYSCONFIG配置时使用I2C时SCL和SDA引脚都是输入模式,但是如果是controller mode 下应该是输出模式,并且这种情况是默认无法修改的
起因是 我想用I2C与OLED通信,但是无法实现,我发现SPI设置是正常的输出模式。
同时我想请各位大佬帮我看看我的代码对不对,主要是向控制器写命令的函数我不太确定

灰常感谢各位
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
在SYSCONFIG配置时使用I2C时SCL和SDA引脚都是输入模式,但是如果是controller mode 下应该是输出模式,并且这种情况是默认无法修改的
起因是 我想用I2C与OLED通信,但是无法实现,我发现SPI设置是正常的输出模式。
同时我想请各位大佬帮我看看我的代码对不对,主要是向控制器写命令的函数我不太确定

灰常感谢各位
你好,
void Write_IIC_Byte(unsigned char IIC_Byte){DL_I2C_transmitControllerData(I2C1, IIC_Byte);}
void DL_I2C_transmitControllerData(I2C_Regs *i2c, uint8_t data),第二个参数属性应该是uint8_t.
在SYSCONFIG配置时使用I2C时SCL和SDA引脚都是输入模式,但是如果是controller mode 下应该是输出模式,
确实无法修改,但是这里输入输出应该是都可以。
你可以参考下SDK中的例程:mspm0_sdk_1_20_01_06\examples\nortos\LP_MSPM0G3507\driverlib\i2c_controller_rw_multibyte_fifo_interrupts
您好,非常感谢您的回复,但是我已经检查了所有例程,基本上都是这样的,我发现下方有自定义引脚,里面可以选择invert选项,按照软件的解释应该是输入转输出,但是这依旧无法解决我OLED亮不了的情况,同时非常感谢您对我代码的建议
以下是我的OLED.c文件
#include "oled.h"
// the storage format is as follow
//[0]0 1 2 3 ... 127
//[1]0 1 2 3 ... 127
//[2]0 1 2 3 ... 127
//[3]0 1 2 3 ... 127
//[4]0 1 2 3 ... 127
//[5]0 1 2 3 ... 127
//[6]0 1 2 3 ... 127
//[7]0 1 2 3 ... 127
/**********************************************
//IIC Start
**********************************************/
void IIC_Start()
{
OLED_SCLK_Set();
OLED_SDIN_Set();
OLED_SDIN_Clr();
OLED_SCLK_Clr();
}
/**********************************************
//IIC Stop
**********************************************/
void IIC_Stop()
{
OLED_SCLK_Set();
// OLED_SCLK_Clr();
OLED_SDIN_Clr();
OLED_SDIN_Set();
}
void IIC_Wait_Ack()
{
OLED_SCLK_Set();
OLED_SCLK_Clr();
}
/**********************************************
// IIC Write byte
**********************************************/
void Write_IIC_Byte(uint8_t IIC_Byte)
{
DL_I2C_transmitControllerData(I2C1, IIC_Byte);
// unsigned char i;
// unsigned char m, da;
// OLED_SCLK_Clr();
// for (i = 0; i < 8; i++)
// {
// m = da;
// // OLED_SCLK_Clr();
// m = m & 0x80;
// if (m == 0x80)
// {
// OLED_SDIN_Set();
// }
// else
// OLED_SDIN_Clr();
// da = da << 1;
// OLED_SCLK_Set();
// delay_us(100);
// OLED_SCLK_Clr();
// }
}
/**********************************************
// IIC Write Command
**********************************************/
void OLED_WR_CMD(unsigned char IIC_Command)
{
IIC_Start();
Write_IIC_Byte(0x78); // Slave address,SA0=0
IIC_Wait_Ack();
Write_IIC_Byte(0x00); // write command
IIC_Wait_Ack();
Write_IIC_Byte(IIC_Command);
IIC_Wait_Ack();
IIC_Stop();
}
/**********************************************
// IIC Write Data
**********************************************/
void OLED_WR_DATA(unsigned char IIC_Data)
{
IIC_Start();
Write_IIC_Byte(0x78); // D/C#=0; R/W#=0
IIC_Wait_Ack();
Write_IIC_Byte(0x40); // write data
IIC_Wait_Ack();
Write_IIC_Byte(IIC_Data);
IIC_Wait_Ack();
IIC_Stop();
}
uint8_t CMD_Data[] = {
0xAE, 0xD5, 0x80, 0xA8, 0x3F, 0xD3, 0x00, 0x40, 0xA1, 0xC8, 0xDA,
0x12, 0x81, 0xCF, 0xD9, 0xF1, 0xDB, 0x40, 0xA4, 0xA6, 0x8D, 0x14,
0xAF};
/**
* @function: void OLED_Init(void)
* @description: OLED初始化
* @return {*}
*/
void OLED_Init(void)
{
delay_ms(200);
uint8_t i = 0;
for (i = 0; i < 23; i++)
{
OLED_WR_CMD(CMD_Data[i]);
}
}
/**
* @function: void OLED_PartClear(void)
* @description: 局部清除
* @return {*}
*/
void OLED_PartClear(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)
{
uint8_t x = 0, y = 0;
if (y1 % 8 == 0)
y = y1 / 8;
else
y = y1 / 8 + 1;
for (y = y0; y < y1; y++)
{
OLED_Set_Pos(x0, y);
for (x = x0; x < x1; x++)
{
OLED_WR_DATA(0);
}
}
}
/**
* @function: OLED_Clear(void)
* @description: 清屏,整个屏幕是黑色的!和没点亮一样!!!
* @return {*}
*/
void OLED_Clear(void)
{
uint8_t i, n;
for (i = 0; i < 8; i++)
{
OLED_WR_CMD(0xb0 + i); // 设置页地址(0~7)
OLED_WR_CMD(0x00); // 设置显示位置—列低地址
OLED_WR_CMD(0x10); // 设置显示位置—列高地址
for (n = 0; n < 128; n++)
{
OLED_WR_DATA(0);
}
}
}
/**
* @function: void OLED_Display_On(void)
* @description: 开启OLED显示
* @return {*}
*/
void OLED_Display_On(void)
{
OLED_WR_CMD(0X8D); // SET DCDC命令
OLED_WR_CMD(0X14); // DCDC ON
OLED_WR_CMD(0XAF); // DISPLAY ON,打开显示
}
/**
* @function: void OLED_Display_Off(void)
* @description: 关闭OLED显示
* @return {*}
*/
void OLED_Display_Off(void)
{
OLED_WR_CMD(0X8D); // SET DCDC命令
OLED_WR_CMD(0X10); // DCDC OFF
OLED_WR_CMD(0XAE); // DISPLAY OFF,关闭显示
}
/**
* @function: void OLED_Set_Pos(uint8_t x, uint8_t y)
* @description: 坐标设置
* @param {uint8_t} x,y
* @return {*}
*/
void OLED_Set_Pos(uint8_t x, uint8_t y)
{
OLED_WR_CMD(0xb0 + y); // 设置页地址(0~7)
OLED_WR_CMD(((x & 0xf0) >> 4) | 0x10); // 设置显示位置—列高地址
OLED_WR_CMD(x & 0x0f); // 设置显示位置—列低地址
}
/**
* @function: unsigned int oled_pow(uint8_t m,uint8_t n)
* @description: m^n函数
* @param {uint8_t} m,n
* @return {unsigned int} result
*/
unsigned int oled_pow(uint8_t m, uint8_t n)
{
unsigned int result = 1;
while (n--)
result *= m;
return result;
}
/**
* @function: void OLED_ShowChar(uint8_t x, uint8_t y, uint8_t chr, uint8_t Char_Size,uint8_t Color_Turn)
* @description: 在OLED12864特定位置开始显示一个字符
* @param {uint8_t} x字符开始显示的横坐标
* @param {uint8_t} y字符开始显示的纵坐标
* @param {uint8_t} chr待显示的字符
* @param {uint8_t} Char_Size待显示字符的字体大小,选择字体 16/12
* @param {uint8_t} Color_Turn是否反相显示(1反相、0不反相)
* @return {*}
*/
void OLED_ShowChar(uint8_t x, uint8_t y, uint8_t chr, uint8_t Char_Size, uint8_t Color_Turn)
{
unsigned char c = 0, i = 0;
c = chr - ' '; // 得到偏移后的值
if (x > 128 - 1)
{
x = 0;
y = y + 2;
}
if (Char_Size == 16)
{
OLED_Set_Pos(x, y);
for (i = 0; i < 8; i++)
{
if (Color_Turn)
OLED_WR_DATA(~F8X16[c * 16 + i]);
else
OLED_WR_DATA(F8X16[c * 16 + i]);
}
OLED_Set_Pos(x, y + 1);
for (i = 0; i < 8; i++)
{
if (Color_Turn)
OLED_WR_DATA(~F8X16[c * 16 + i + 8]);
else
OLED_WR_DATA(F8X16[c * 16 + i + 8]);
}
}
else
{
OLED_Set_Pos(x, y);
for (i = 0; i < 6; i++)
{
if (Color_Turn)
OLED_WR_DATA(~F6x8[c][i]);
else
OLED_WR_DATA(F6x8[c][i]);
}
}
}
/**
* @function: void OLED_ShowString(uint8_t x, uint8_t y, uint8_t *chr, uint8_tChar_Size, uint8_t Color_Turn)
* @description: 在OLED12864特定位置开始显示字符串
* @param {uint8_t} x待显示字符串的开始横坐标x:0~127
* @param {uint8_t} y待显示字符串的开始纵坐标 y:0~7,若选择字体大小为16,则两行数字之间需要间隔2,若选择字体大小为12,间隔1
* @param {uint8_t} *chr待显示的字符串
* @param {uint8_t} Char_Size待显示字符串的字体大小,选择字体 16/12,16为8X16,12为6x8
* @param {uint8_t} Color_Turn是否反相显示(1反相、0不反相)
* @return {*}
*/
void OLED_ShowString(uint8_t x, uint8_t y, char *chr, uint8_t Char_Size, uint8_t Color_Turn)
{
uint8_t j = 0;
while (chr[j] != '\0')
{
OLED_ShowChar(x, y, chr[j], Char_Size, Color_Turn);
if (Char_Size == 12) // 6X8的字体列加6,显示下一个字符
x += 6;
else // 8X16的字体列加8,显示下一个字符
x += 8;
if (x > 122 && Char_Size == 12) // TextSize6x8如果一行不够显示了,从下一行继续显示
{
x = 0;
y++;
}
if (x > 120 && Char_Size == 16) // TextSize8x16如果一行不够显示了,从下一行继续显示
{
x = 0;
y++;
}
j++;
}
}
/**
* @function: void OLED_ShowNum(uint8_t x,uint8_t y,unsigned int num,uint8_t len,uint8_t size2, Color_Turn)
* @description: 显示数字
* @param {uint8_t} x待显示的数字起始横坐标,x:0~126
* @param {uint8_t} y待显示的数字起始纵坐标, y:0~7,若选择字体大小为16,则两行数字之间需要间隔2,若选择字体大小为12,间隔1
* @param {unsigned int} num:输入的数据
* @param {uint8_t } len:输入的数据位数
* @param {uint8_t} size2:输入的数据大小,选择 16/12,16为8X16,12为6x8
* @param {uint8_t} Color_Turn是否反相显示(1反相、0不反相)
* @return {*}
*/
void OLED_ShowNum(uint8_t x, uint8_t y, unsigned int num, uint8_t len, uint8_t size2, uint8_t Color_Turn)
{
uint8_t t, temp;
uint8_t enshow = 0;
for (t = 0; t < len; t++)
{
temp = (num / oled_pow(10, len - t - 1)) % 10;
if (enshow == 0 && t < (len - 1))
{
if (temp == 0)
{
OLED_ShowChar(x + (size2 / 2) * t, y, ' ', size2, Color_Turn);
continue;
}
else
enshow = 1;
}
OLED_ShowChar(x + (size2 / 2) * t, y, temp + '0', size2, Color_Turn);
}
}
/**
* @function: void OLED_Showdecimal(uint8_t x,uint8_t y,float num,uint8_t z_len,uint8_t f_len,uint8_t size2, uint8_t Color_Turn)
* @description: 显示正负浮点数
* @param {uint8_t} x待显示的数字起始横坐标,x:0~126
* @param {uint8_t} y待显示的数字起始纵坐标, y:0~7,若选择字体大小为16,则两行数字之间需要间隔2,若选择字体大小为12,间隔1
* @param {float} num:输入的浮点型数据
* @param {uint8_t } z_ len:整数部分的位数
* @param {uint8_t } f_len: 小数部分的位数
* @param {uint8_t} size2:输入的数据大小,选择 16/12,16为8X16,12为6x8
* @param {uint8_t} Color_Turn是否反相显示(1反相、0不反相)
* @return {*}
*/
void OLED_Showdecimal(uint8_t x, uint8_t y, float num, uint8_t z_len, uint8_t f_len, uint8_t size2, uint8_t Color_Turn)
{
uint8_t t, temp, i = 0; // i为负数标志位
uint8_t enshow;
int z_temp, f_temp;
if (num < 0)
{
z_len += 1;
i = 1;
num = -num;
}
z_temp = (int)num;
// 整数部分
for (t = 0; t < z_len; t++)
{
temp = (z_temp / oled_pow(10, z_len - t - 1)) % 10;
if (enshow == 0 && t < (z_len - 1))
{
if (temp == 0)
{
OLED_ShowChar(x + (size2 / 2) * t, y, ' ', size2, Color_Turn);
continue;
}
else
enshow = 1;
}
OLED_ShowChar(x + (size2 / 2) * t, y, temp + '0', size2, Color_Turn);
}
// 小数点
OLED_ShowChar(x + (size2 / 2) * (z_len), y, '.', size2, Color_Turn);
f_temp = (int)((num - z_temp) * (oled_pow(10, f_len)));
// 小数部分
for (t = 0; t < f_len; t++)
{
temp = (f_temp / oled_pow(10, f_len - t - 1)) % 10;
OLED_ShowChar(x + (size2 / 2) * (t + z_len) + 5, y, temp + '0', size2, Color_Turn);
}
if (i == 1) // 如果为负,就将最前的一位赋值‘-’
{
OLED_ShowChar(x, y, '-', size2, Color_Turn);
i = 0;
}
}
/**
* @function: void OLED_ShowCHinese(uint8_t x,uint8_t y,uint8_t no, uint8_t Color_Turn)
* @description: 在OLED特定位置开始显示16X16汉字
* @param {uint8_t} x待显示的汉字起始横坐标x: 0~112,两列汉字之间需要间隔16
* @param {uint8_t} y待显示的汉字起始纵坐标 y: 0~6 , 两行汉字之间需要间隔2
* @param {uint8_t} no待显示的汉字编号
* @param {uint8_t} Color_Turn是否反相显示(1反相、0不反相)
* @return {*}
*/
void OLED_ShowCHinese(uint8_t x, uint8_t y, uint8_t no, uint8_t Color_Turn)
{
uint8_t t = 0;
OLED_Set_Pos(x, y);
for (t = 0; t < 16; t++)
{
if (Color_Turn)
OLED_WR_DATA(~Hzk[2 * no][t]); // 显示汉字的上半部分
else
OLED_WR_DATA(Hzk[2 * no][t]); // 显示汉字的上半部分
}
OLED_Set_Pos(x, y + 1);
for (t = 0; t < 16; t++)
{
if (Color_Turn)
OLED_WR_DATA(~Hzk[2 * no + 1][t]); // 显示汉字的上半部分
else
OLED_WR_DATA(Hzk[2 * no + 1][t]); // 显示汉字的上半部分
}
}
/**
* @function: void OLED_DrawBMP(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t * BMP,uint8_t Color_Turn)
* @description: 在OLED特定区域显示BMP图片
* @param {uint8_t} x0图像开始显示横坐标 x0:0~127
* @param {uint8_t} y0图像开始显示纵坐标 y0:0~7
* @param {uint8_t} x1图像结束显示横坐标 x1:1~128
* @param {uint8_t} y1图像结束显示纵坐标 y1:1~8
* @param {uint8_t} *BMP待显示的图像数据
* @param {uint8_t} Color_Turn是否反相显示(1反相、0不反相)
* @return {*}
*/
void OLED_DrawBMP(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t *BMP, uint8_t Color_Turn)
{
uint32_t j = 0;
uint8_t x = 0, y = 0;
if (y1 % 8 == 0)
y = y1 / 8;
else
y = y1 / 8 + 1;
for (y = y0; y < y1; y++)
{
OLED_Set_Pos(x0, y);
for (x = x0; x < x1; x++)
{
if (Color_Turn)
OLED_WR_DATA(~BMP[j++]); // 显示反相图片
else
OLED_WR_DATA(BMP[j++]); // 显示图片
}
}
}
/**
* @function: void OLED_HorizontalShift(uint8_t direction)
* @description: 屏幕内容水平全屏滚动播放
* @param {uint8_t} direction LEFT 0x27 RIGHT 0x26
* @return {*}
*/
void OLED_HorizontalShift(uint8_t direction)
{
OLED_WR_CMD(0x2e); // 停止滚动
OLED_WR_CMD(direction); // 设置滚动方向
OLED_WR_CMD(0x00); // 虚拟字节设置,默认为0x00
OLED_WR_CMD(0x00); // 设置开始页地址
OLED_WR_CMD(0x07); // 设置每个滚动步骤之间的时间间隔的帧频
// 0x00-5帧, 0x01-64帧, 0x02-128帧, 0x03-256帧, 0x04-3帧, 0x05-4帧, 0x06-25帧, 0x07-2帧,
OLED_WR_CMD(0x07); // 设置结束页地址
OLED_WR_CMD(0x00); // 虚拟字节设置,默认为0x00
OLED_WR_CMD(0xff); // 虚拟字节设置,默认为0xff
OLED_WR_CMD(0x2f); // 开启滚动-0x2f,禁用滚动-0x2e,禁用需要重写数据
}
/**
* @function: void OLED_Some_HorizontalShift(uint8_t direction,uint8_t start,uint8_t end)
* @description: 屏幕部分内容水平滚动播放
* @param {uint8_t} direction LEFT 0x27 RIGHT 0x26
* @param {uint8_t} start 开始页地址 0x00~0x07
* @param {uint8_t} end 结束页地址 0x01~0x07
* @return {*}
*/
void OLED_Some_HorizontalShift(uint8_t direction, uint8_t start, uint8_t end)
{
OLED_WR_CMD(0x2e); // 停止滚动
OLED_WR_CMD(direction); // 设置滚动方向
OLED_WR_CMD(0x00); // 虚拟字节设置,默认为0x00
OLED_WR_CMD(start); // 设置开始页地址
OLED_WR_CMD(0x07); // 设置每个滚动步骤之间的时间间隔的帧频,0x07即滚动速度2帧
OLED_WR_CMD(end); // 设置结束页地址
OLED_WR_CMD(0x00); // 虚拟字节设置,默认为0x00
OLED_WR_CMD(0xff); // 虚拟字节设置,默认为0xff
OLED_WR_CMD(0x2f); // 开启滚动-0x2f,禁用滚动-0x2e,禁用需要重写数据
}
/**
* @function: void OLED_VerticalAndHorizontalShift(uint8_t direction)
* @description: 屏幕内容垂直水平全屏滚动播放
* @param {uint8_t} direction 右上滚动 0x29
* 左上滚动 0x2A
* @return {*}
*/
void OLED_VerticalAndHorizontalShift(uint8_t direction)
{
OLED_WR_CMD(0x2e); // 停止滚动
OLED_WR_CMD(direction); // 设置滚动方向
OLED_WR_CMD(0x01); // 虚拟字节设置
OLED_WR_CMD(0x00); // 设置开始页地址
OLED_WR_CMD(0x07); // 设置每个滚动步骤之间的时间间隔的帧频,即滚动速度
OLED_WR_CMD(0x07); // 设置结束页地址
OLED_WR_CMD(0x01); // 垂直滚动偏移量
OLED_WR_CMD(0x00); // 虚拟字节设置,默认为0x00
OLED_WR_CMD(0xff); // 虚拟字节设置,默认为0xff
OLED_WR_CMD(0x2f); // 开启滚动-0x2f,禁用滚动-0x2e,禁用需要重写数据
}
/**
* @function: void OLED_DisplayMode(uint8_t mode)
* @description: 屏幕内容取反显示
* @param {uint8_t} direction ON 0xA7 ,
* OFF 0xA6 默认此模式,设置像素点亮
* @return {*}
*/
void OLED_DisplayMode(uint8_t mode)
{
OLED_WR_CMD(mode);
}
/**
* @function: void OLED_IntensityControl(uint8_t intensity)
* @description: 屏幕亮度调节
* @param {uint8_t} intensity 0x00~0xFF,RESET=0x7F
* @return {*}
*/
void OLED_IntensityControl(uint8_t intensity)
{
OLED_WR_CMD(0x81);
OLED_WR_CMD(intensity);
}
这是我的oled.h
#ifndef __OLED_H #define __OLED_H #include <ti_msp_dl_config.h> #include "delay.h" #include "oledfont.h" #define OLED_MODE 0 #define SIZE 8 #define XLevelL 0x00 #define XLevelH 0x10 #define Max_Column 128 #define Max_Row 64 #define Brightness 0xFF #define X_WIDTH 128 #define Y_WIDTH 64 #define OLED_SCLK_Clr() DL_GPIO_clearPins(GPIO_I2C_SCL_PORT, GPIO_I2C_SCL_PIN) // CLK #define OLED_SCLK_Set() DL_GPIO_setPins(GPIO_I2C_SCL_PORT, GPIO_I2C_SCL_PIN) #define OLED_SDIN_Clr() DL_GPIO_clearPins(GPIO_I2C_SDA_PORT, GPIO_I2C_SDA_PIN) // DIN #define OLED_SDIN_Set() DL_GPIO_setPins(GPIO_I2C_SDA_PORT, GPIO_I2C_SDA_PIN) #define OLED_CMD 0 #define OLED_DATA 1 // Functions to control OLED are as follows void OLED_WR_CMD(uint8_t cmd); void OLED_WR_DATA(uint8_t data); void write_IIC_Byte(unsigned char IIC_Byte); void OLED_Init(void); void OLED_Clear(void); void OLED_Display_On(void); void OLED_Display_Off(void); void OLED_Set_Pos(uint8_t x, uint8_t y); void OLED_PartClear(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1); void OLED_ShowNum(uint8_t x, uint8_t y, unsigned int num, uint8_t len, uint8_t size2, uint8_t Color_Turn); void OLED_Showdecimal(uint8_t x, uint8_t y, float num, uint8_t z_len, uint8_t f_len, uint8_t size2, uint8_t Color_Turn); void OLED_ShowChar(uint8_t x, uint8_t y, uint8_t chr, uint8_t Char_Size, uint8_t Color_Turn); void OLED_ShowString(uint8_t x, uint8_t y, char *chr, uint8_t Char_Size, uint8_t Color_Turn); void OLED_ShowCHinese(uint8_t x, uint8_t y, uint8_t no, uint8_t Color_Turn); void OLED_DrawBMP(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t *BMP, uint8_t Color_Turn); void OLED_HorizontalShift(uint8_t direction); void OLED_Some_HorizontalShift(uint8_t direction, uint8_t start, uint8_t end); void OLED_VerticalAndHorizontalShift(uint8_t direction); void OLED_DisplayMode(uint8_t mode); void OLED_IntensityControl(uint8_t intensity); #endif
感谢您的建议,我尝试使用模拟IO与OLED通信,但是还是不行
void IIC_Start()
{
delay_us(1);
OLED_SCLK_Set();
delay_us(1);
OLED_SDIN_Set();
delay_us(1);
OLED_SDIN_Clr();
}
/**********************************************
//IIC Stop
**********************************************/
void IIC_Stop()
{
delay_us(1);
OLED_SCLK_Set();
delay_us(1);
OLED_SDIN_Clr();
delay_us(1);
OLED_SDIN_Set();
}
void IIC_Wait_Ack()
{
delay_us(1);
OLED_SCLK_Set();
delay_us(1);
OLED_SCLK_Clr();
}
/**********************************************
// IIC Write byte
**********************************************/
void Write_IIC_Byte(uint8_t IIC_Byte)
{
uint8_t i;
uint8_t m, da;
da = IIC_Byte;
OLED_SCLK_Clr();
delay_us(1);
for (i = 0; i < 8; i++)
{
m = da;
m = m & 0x80;
if (m == 0x80)
{
OLED_SDIN_Set();
}
else
OLED_SDIN_Clr();
da = da << 1;
delay_us(1);
OLED_SCLK_Set();
delay_us(1);
OLED_SCLK_Clr();
delay_us(1);
}
}
这是我的配置文件
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "MSPM0G350X" --package "LQFP-64(PM)" --part "Default" --product "mspm0_sdk@1.20.01.06"
* @versions {"tool":"1.18.0+3266"}
*/
/**
* Import the modules used in this configuration.
*/
const GPIO = scripting.addModule("/ti/driverlib/GPIO", {}, false);
const GPIO1 = GPIO.addInstance();
const GPIO2 = GPIO.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
GPIO1.$name = "LED";
GPIO1.associatedPins.create(2);
GPIO1.associatedPins[0].assignedPin = "26";
GPIO1.associatedPins[0].ioStructure = "SD";
GPIO1.associatedPins[0].$name = "RED";
GPIO1.associatedPins[0].assignedPort = "PORTB";
GPIO1.associatedPins[1].assignedPin = "27";
GPIO1.associatedPins[1].ioStructure = "SD";
GPIO1.associatedPins[1].$name = "GREEN";
GPIO1.associatedPins[1].assignedPort = "PORTB";
const Board = scripting.addModule("/ti/driverlib/Board", {}, false);
Board.peripheral.$assign = "DEBUGSS";
Board.peripheral.swclkPin.$assign = "PA20";
Board.peripheral.swdioPin.$assign = "PA19";
GPIO2.$name = "GPIO_I2C";
GPIO2.associatedPins.create(2);
GPIO2.associatedPins[0].$name = "SCL";
GPIO2.associatedPins[0].ioStructure = "SD";
GPIO2.associatedPins[0].initialValue = "SET";
GPIO2.associatedPins[0].internalResistor = "PULL_UP";
GPIO2.associatedPins[0].pin.$assign = "PB7";
GPIO2.associatedPins[1].$name = "SDA";
GPIO2.associatedPins[1].internalResistor = "PULL_UP";
GPIO2.associatedPins[1].ioStructure = "SD";
GPIO2.associatedPins[1].initialValue = "SET";
GPIO2.associatedPins[1].pin.$assign = "PB6";
const SYSCTL = scripting.addModule("/ti/driverlib/SYSCTL", {}, false);
SYSCTL.forceDefaultClkConfig = true;
SYSCTL.clockTreeEn = true;
/**
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
* re-solve from scratch.
*/
GPIO1.associatedPins[0].pin.$suggestSolution = "PB26";
GPIO1.associatedPins[1].pin.$suggestSolution = "PB27";
我加入了内置的上拉电阻,但是OLED依旧没有反应,但是我的OLED在其他设备上是可以正常使用的,我将系统板上的LED与I2C的两条线相连,灯在闪烁至少显示引脚通信是没有问题的,也非常感谢您的耐心帮助