在线时间613 小时
UID252169
注册时间2010-12-5
NXP金币0
TA的每日心情 | 开心 2019-2-14 16:49 |
---|
签到天数: 296 天 连续签到: 1 天 [LV.8]以坛为家I
金牌会员
 
- 积分
- 4473
- 最后登录
- 2020-4-14
|
在看到LPC8xx系列已出LPC845芯片,心动就从官网申请了几片芯片,型号为:LPC845M301JDB64——64管脚0.5mm间距密排的芯片,并且参考手册自己设计了一块实验板,见照片11——PCB正面,12——PCB背面。
焊上各种元器件和插针后见照片13——正面,照片14 ——反面。
板子好了才发现这块开发板的应用资料奇缺,搜了一堆网站和各种论坛最后下载了一个看似采用LPCXpresso完成的一类似RTC系统的工程——也仅仅只有这个工程运行成功了,其他的工程无法开展试验。
IAR下缺少LPC845的设备驱动,Keil无法下载其LPC800系列的1.6.0的库文件包而无法使用keil——甚至于下载最新升级版的Keil5.25pre也无可奈何。最后只好在这个下边进行测试。平台为Keil5.23。工程名称为:LPC84x-LPCXpresso。
由于初次接触这类的系统,打开后的默认编译居然报27个警告,好在警告无碍下载,下载也没有报错,但毫无结果——经查,我的板子采用了P0_00,P0_14,P0_29,P0_31,前3个为1只RGB3色LED,后P0_31是另1只RGBLED的蓝色LED,红色和绿色用于SWDIO,SWCLK引脚检测了。
遍历文档找到设置LED的文件:LED_LPC84x-LPCXpresso.c,此文档定义了LED,为了实现4线LCD自己又加了4个引脚定义[板子纵列的7孔插孔]:
#define LED_NUM (8U)//原来是3U,我的板子有4个LED
const uint32_t led_mask[] = {1U<<0,1U<<14,1U<<29,1U<<31,1U<<16,1U<<17,1U<<18,1U<<19};//Px_y
const uint32_t led_port[] = { 0, 0, 0, 0, 1, 1, 1, 1};//Portx
这样P0定义4个连接4只LED为用户测试LED,P1口定义4个模拟串口驱显串口KS0713 LCD。
原main代码:
#include <stdio.h>
#include "cmsis_os2.h"//::CMSIS:RTOS2
#include "Board_LED.h"//::Board Support ED
#include "Board_Buttons.h"//::Board Support:Buttons
#include "RTE_Components.h"//Component selection
#include "0713.h"//自编的0713驱显模块
//#include CMSIS_device_header
#ifdef RTE_Compiler_EventRecorder
#include "EventRecorder.h"
#endif
#ifndef RTE_CMSIS_RTOS2_RTX5
#error This example works only with CMSIS-RTOS2 RTX5 implementation!
#endif
void delay(int counter);
volatile int32_t delay_val=100;//延时时间减少到100mS,原为500mS
int k;//为了刷显ASCII码定义的外联变量
osThreadId_t tid_thrLED;//Thread id of thread: LED
osThreadId_t tid_thrBUT;//Thread id of thread: BUT
//thrLED: blink LED
void thrLED(void *argument) {
uint32_t led_max = 3;//LED_GetCount();0~3代表4只LED
uint32_t led_num = 0;
for (;;) {
osThreadFlagsWait(0x0001, osFlagsWaitAny ,osWaitForever);
LED_On(led_num); //Turn specified LED on
osThreadFlagsWait(0x0001, osFlagsWaitAny ,osWaitForever);
LED_Off(led_num); //Turn specified LED off
led_num++; //Change LED number
//if (led_num >= led_max) {
if (led_num > 3) {
led_num = 0; //Restart with first LED
}
}
}
//thrBUT: check button state
void thrBUT(void *argument){
uint32_t button_msk = (1U << Buttons_GetCount()) - 1;
for (;;){
dispAsc();
osDelay(delay_val); /* Wait */
while (Buttons_GetState() & (button_msk)); /* Wait while holding USER button */
osThreadFlagsSet(tid_thrLED, 0x0001);
lcdClear();
}
}
//Application main thread
void app_main (void *argument) {
tid_thrBUT = osThreadNew (thrBUT, NULL, NULL);//create BUT thread
tid_thrLED = osThreadNew (thrLED, NULL, NULL);//create LED thread
for (;;) {}
}
//Delayer
void delay(int counter){
int32_t i,j;
for(i=0;i<counter;i++){for(j=0;j<i;j++){;}}
}
//main: create tasks and start kernel
int main (void) {
//System Initialization
//SystemInit();
SystemCoreClockUpdate();
LED_Initialize(); //initalize LEDs
Buttons_Initialize(); //initalize Buttons
lcdInit(); //LCD 初始化
lcdClear(); //清屏
#ifdef RTE_Compiler_EventRecorder
EventRecorderInitialize(EventRecordAPI,1U);//Initialize and start Event Recorder
#endif
osKernelInitialize(); //Initialize CMSIS-RTOS
osThreadNew(app_main,NULL,NULL); //create application main thread
if(osKernelGetState()==osKernelReady){osKernelStart();}//start thread execution
while(1){
;
}
}
最后的结果是4只LED循环点亮:红、率、蓝、蓝,LCD刷新显示一次。照片15是拿掉LCD,观察LED轮闪动画;照片16,17是插上LCD显示刷屏ASCII码。
|
|