这oled屏在stm32上驱动没问题,同样的程序在msp430无法显示,编译通过都没错

这oled屏在stm32上驱动没问题,同样的程序在msp430无法显示,编译通过都没错,第1张

我做过stm32和msp430,我觉得问题应该出在以下几个方面:

1.I/O配置错误:单片机与屏驱动芯片相连的I/袭粗O变了,在程序移植后没有修改,造成数据的读写错姿搭误。

2.延迹禅拿时程序:STM32主频是72MHz,而MSP430是8MHZ,相差很多,原来的演示程序不试用430。在对驱动芯片读写过程中调用延时函数,由于延时不匹配,造成读写失败。

具体配置过程:

1、打开STM32CubeMX,并选择好相应的芯片。文中的芯片为STM32F207VCT6,选择后如下图:

2、配置RCC时钟、ETH、PA8以及使能LWIP;

由于此处我们的开发板硬件上为RMII方式,因此选择ETH-RMII,若有同志的开发板为MII方式,请参考MII的配置方法,此处只针对RMII;

RCC选择外部时钟源,另外勾选MCO1,软件会自动将PA8配置为MCO1模式,该引脚对于RMII方式很重要,用于为PHY芯片提供50MHz时钟;

使能LWIP;

3、时钟树的相关配置,必须保证MCO1输出为50Mhz,如果这个频率不对会导致PHY芯片无法工作;

我这里因为芯片为207VCT6,为了使MCO1输出为50Mhz,做了PLL倍频参数的一些调整,总谈喊铅体如下:(同志们配置时可根据自己的芯片灵活配置,但需保证MCO1的输出为50Mhz)

4、ETH、LWIP、RCC相关参数设置;

至此,比较重要的都在前面了,但是还有一点仍需要注意,即PA8引脚输出速度,几次不成功都是因为这个引脚没注意。

后续的参数设置可以根据同志们自己的需求分别设置,这里给出我的设置供参考;

ETH参数保持默认,但中断勾选一下;

LWIP参数设置如下:(因为我这里是配置UDP服务器,IP选择静态分配)

5、生成工程,做最后的函数修改;

给生成的工程添加UDP服务器的初始化以及端口绑定等相关函数;

我这里直接将之前的官方例程中的UDP服务器文件加进来,如下:

之后将.c文件添加到用户程序,主函数添加Udp的.h头文件;如下:(udp文件的具体内容在后面给出)

6、主含好函数还需要添加一下几个函数,在这渗虚里不对函数作用及实现原理讲解,仅做添加说明。

附:udp_echoserver相关文件内容(该文件为官方的示例程序,版权归官方,此处做转载)

udp_echoserver.c的内容如下:

/* Includes ------------------------------------------------------------------*/

#include "main.h"

#include "lwip/pbuf.h"

#include "lwip/udp.h"

#include "lwip/tcp.h"

#include <string.h>

#include <stdio.h>

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

#define UDP_SERVER_PORT7 /* define the UDP local connection port */

#define UDP_CLIENT_PORT7 /* define the UDP remote connection port */

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/

void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)

/* Private functions ---------------------------------------------------------*/

/**

* @brief Initialize the server application.

* @param None

* @retval None

*/

void udp_echoserver_init(void)

{

struct udp_pcb *upcb

err_t err

/* Create a new UDP control block */

upcb = udp_new()

if (upcb)

{

/* Bind the upcb to the UDP_PORT port */

/* Using IP_ADDR_ANY allow the upcb to be used by any local interface */

err = udp_bind(upcb, IP_ADDR_ANY, UDP_SERVER_PORT)

if(err == ERR_OK)

{

/* Set a receive callback for the upcb */

udp_recv(upcb, udp_echoserver_receive_callback, NULL)

}

}

}

/**

* @brief This function is called when an UDP datagrm has been received on the port UDP_PORT.

* @param arg user supplied argument (udp_pcb.recv_arg)

* @param pcb the udp_pcb which received data

* @param p the packet buffer that was received

* @param addr the remote IP address from which the packet was received

* @param port the remote port from which the packet was received

* @retval None

*/

void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)

{

/* Connect to the remote client */

udp_connect(upcb, addr, UDP_CLIENT_PORT)

/* Tell the client that we have accepted it */

udp_send(upcb, p)

/* free the UDP connection, so we can accept new clients */

udp_disconnect(upcb)

/* Free the p buffer */

pbuf_free(p)

}

udp_echoserver.h的内容如下:

#ifndef __ECHO_H__

#define __ECHO_H__

void udp_echoserver_init(void)

#endif /* __MINIMAL_ECHO_H */

7、至此,所有的工作完成,编译工程,下载至开发板。由于udp_echoserver中绑定的端口号为7,这里我们通过测试工具测试网络的功能,


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12529146.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存