STM32F767ZI test for Time,ADC,PWM,Intrrupt input,IO input,IO plus,and Virual SPI 4 line LCD display.

Files at this revision

API Documentation at this revision

Comitter:
zhjb62
Date:
Sun Jul 30 13:00:37 2017 +0000
Commit message:
1 tick,1 plus,4 adc input to check,3 pwm,2 Interrupt input,3 input,with 6903 LCD display,1 programe counter.

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
6903.h Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
img/uvision.png Show annotated file Show diff for this revision Revisions of this file
main6903.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Sun Jul 30 13:00:37 2017 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/6903.h	Sun Jul 30 13:00:37 2017 +0000
@@ -0,0 +1,108 @@
+//#include "mbed.h"
+DigitalOut dat(PD_4);
+DigitalOut clk(PD_5);
+DigitalOut res(PD_6);
+DigitalOut reg(PD_7);
+
+//6903 102X64LCD
+const unsigned char asc2[][6]={//8x6 Dots 32-126[0-94]
+{0x00,0x3E,0x45,0x49,0x51,0x3E},//0
+{0x00,0x00,0x21,0x7F,0x01,0x00},//1
+{0x00,0x31,0x43,0x45,0x49,0x31},//2
+{0x00,0x22,0x49,0x49,0x49,0x36},//3
+{0x00,0x04,0x0C,0x14,0x7F,0x04},//4
+{0x00,0x72,0x51,0x51,0x51,0x4E},//5-5
+{0x00,0x3E,0x49,0x49,0x49,0x06},//6
+{0x00,0x40,0x43,0x4C,0x50,0x60},//7
+{0x00,0x36,0x49,0x49,0x49,0x36},//8
+{0x00,0x30,0x48,0x48,0x48,0x3F},//9
+{0x00,0x1F,0x24,0x64,0x24,0x1F},//A-10
+{0x00,0x41,0x7F,0x49,0x49,0x36},//B
+{0x00,0x3E,0x41,0x41,0x41,0x22},//C
+{0x00,0x41,0x7F,0x41,0x41,0x3E},//D
+{0x00,0x41,0x7F,0x49,0x49,0x63},//E
+{0x00,0x41,0x7F,0x49,0x5C,0x60},//F-15
+{0x00,0x3E,0x41,0x45,0x47,0x24},//G
+{0x41,0x7F,0x08,0x08,0x08,0x7F},//H
+{0x00,0x00,0x41,0x7F,0x41,0x00},//I
+{0x00,0x42,0x41,0x7F,0x40,0x40},//J
+{0x00,0x41,0x7F,0x59,0x24,0x43},//K-20
+{0x00,0x40,0x7F,0x41,0x01,0x03},//L
+{0x00,0x7F,0x20,0x1E,0x20,0x7F},//M
+{0x00,0x7F,0x30,0x18,0x06,0x7F},//N
+{0x00,0x3E,0x41,0x41,0x41,0x3E},//O
+{0x00,0x41,0x7F,0x49,0x48,0x30},//P-25
+{0x00,0x3E,0x41,0x47,0x42,0x3D},//Q
+{0x00,0x41,0x7F,0x49,0x4C,0x33},//R
+{0x00,0x32,0x49,0x49,0x49,0x26},//S
+{0x00,0x60,0x41,0x7F,0x41,0x60},//T
+{0x00,0x7E,0x01,0x01,0x01,0x7E},//U-30
+{0x00,0x7C,0x02,0x01,0x02,0x7C},//V
+{0x00,0x7C,0x03,0x3C,0x03,0x7C},//W
+{0x00,0x43,0x24,0x18,0x24,0x43},//X
+{0x00,0x60,0x18,0x07,0x18,0x60},//Y
+{0x00,0x63,0x45,0x49,0x51,0x63},//Z-35
+{0x00,0x00,0x00,0x01,0x00,0x00},//.
+{0x00,0x14,0x14,0x14,0x14,0x14},//=
+{0x00,0x08,0x08,0x3E,0x08,0x08},//+
+{0x00,0x08,0x08,0x08,0x08,0x08},//-
+{0x00,0x00,0x00,0x24,0x00,0x00},//:-40
+};
+//Write Plus
+void wri(void){clk=0;clk=1;}
+//使用SPI接口写数据到LCD,dt:写入的数据 command: 1-数据/0-命令
+void b2l(unsigned char dt,unsigned char command){
+ unsigned char i;
+ reg=command;  
+ for(i=0;i<8;i++){
+  if(dt&0x80) dat=1;else dat=0;
+  dt=dt<<1;    
+  wri();
+ }  
+}
+//名称: 设置坐标函数,参数:X:0-83 Y:0-5
+void setXY(unsigned char X,unsigned char Y){
+ b2l(0x40+Y,0);//column
+ b2l(0x80+X,0);//row
+}
+//名称: LCD清屏函数
+void lcdClear(void){
+ unsigned char t,k;
+ setXY(0,0);
+ for(t=0;t<9;t++){for(k=0;k<102;k++){b2l(0x00,1);}}
+}
+//名称: 显示英文字符,参数:c:显示的字符在asc2表格中的位置
+void c2l(unsigned char x,unsigned char y,unsigned char c){
+ unsigned char line;
+ setXY(x*6,y);    
+ for(line=0;line<6;line++)b2l(asc2[c][line],1);
+}
+//名称: 6903LCD初始化函数
+void lcdInit(void){
+ wait(0.1);
+ res=0;
+ wait(0.5);
+ res=1;
+ wait(0.5);   
+ b2l(0x25,0);//00100 PD=1dcOn|=0Dcoff V=0Up|=1Left H==1
+ wait(0.05);
+ b2l(0x15,0);//脉宽L000~111=1/6-1/7-1/8-1/9//14=1/7
+ wait(0.05);
+ b2l(0x94,0);//设置VOP值,约为8.96V
+ wait(0.05);
+ b2l(0x20,0);//PD=0,H=0,V=0
+ b2l(0x0C,0);//LCD设置完成
+ wait(0.5);
+}
+//Display ASCII Test
+void dispAsc(void){
+ int i,j,k=0;
+ for(i=0;i<8;i++){
+  for(j=0;j<17;j++){
+   c2l(j,i,k);
+   if(k>39){k=0;}else{k++;}
+  }
+ }
+}
+//END Files//
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Sun Jul 30 13:00:37 2017 +0000
@@ -0,0 +1,87 @@
+# Getting started with Blinky on mbed OS
+
+This guide reviews the steps required to get Blinky working on an mbed OS platform.
+
+Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
+
+## Import the example application
+
+From the command-line, import the example:
+
+```
+mbed import mbed-os-example-blinky
+cd mbed-os-example-blinky
+```
+
+### Now compile
+
+Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
+
+```
+mbed compile -m K64F -t ARM
+```
+
+Your PC may take a few minutes to compile your code. At the end, you see the following result:
+
+```
+[snip]
++----------------------------+-------+-------+------+
+| Module                     | .text | .data | .bss |
++----------------------------+-------+-------+------+
+| Misc                       | 13939 |    24 | 1372 |
+| core/hal                   | 16993 |    96 |  296 |
+| core/rtos                  |  7384 |    92 | 4204 |
+| features/FEATURE_IPV4      |    80 |     0 |  176 |
+| frameworks/greentea-client |  1830 |    60 |   44 |
+| frameworks/utest           |  2392 |   512 |  292 |
+| Subtotals                  | 42618 |   784 | 6384 |
++----------------------------+-------+-------+------+
+Allocated Heap: unknown
+Allocated Stack: unknown
+Total Static RAM memory (data + bss): 7168 bytes
+Total RAM memory (data + bss + heap + stack): 7168 bytes
+Total Flash memory (text + data + misc): 43402 bytes
+Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin
+```
+
+### Program your board
+
+1. Connect your mbed device to the computer over USB.
+1. Copy the binary file to the mbed device.
+1. Press the reset button to start the program.
+
+The LED on your platform turns on and off.
+
+## Export the project to Keil MDK, and debug your application
+
+From the command-line, run the following command:
+
+```
+mbed export -m K64F -i uvision
+```
+
+To debug the application:
+
+1. Start uVision.
+1. Import the uVision project generated earlier.
+1. Compile your application, and generate an `.axf` file.
+1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger).
+1. Set breakpoints, and start a debug session.
+
+![Image of uVision](img/uvision.png)
+
+## Troubleshooting
+
+1. Make sure `mbed-cli` is working correctly and its version is `>1.0.0`
+
+ ```
+ mbed --version
+ ```
+
+ If not, you can update it:
+
+ ```
+ pip install mbed-cli --upgrade
+ ```
+
+2. If using Keil MDK, make sure you have a license installed. [MDK-Lite](http://www.keil.com/arm/mdk.asp) has a 32 KB restriction on code size.
\ No newline at end of file
Binary file img/uvision.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main6903.cpp	Sun Jul 30 13:00:37 2017 +0000
@@ -0,0 +1,102 @@
+#include "mbed.h"
+#include "6903.h"
+
+DigitalOut led1(PB_0);
+DigitalOut led2(PB_7);
+DigitalOut led3(PB_14);
+AnalogIn adc0(PA_3);
+AnalogIn adc1(PC_0);
+AnalogIn adc2(PC_3);
+AnalogIn adc3(PF_3);
+PwmOut pwm0(PA_7);
+PwmOut pwm1(PD_14);
+PwmOut pwm2(PD_15);
+//PwmOut pwm3(PF_13);
+DigitalOut plusF12(PF_12);
+Ticker tick;
+InterruptIn plusInE9(PE_9);
+InterruptIn plusInF15(PF_15);
+DigitalIn inPutE12(PE_12);
+DigitalIn inPutE14(PE_14);
+DigitalIn inPutE15(PE_15);
+
+uint16_t i=0,adcCount=0,adcTimes=64,pwmdir0=1,pwmdir1=1,pwmdir2=1,pe9,pf15;
+float val0,val1,val2,val3,duty,dut0=0.01f,dut1=0.01f,dut2=0.01f,ddu0=0.01f,ddu1=0.02f,ddu2=0.03f;
+uint32_t js,adcTemp;
+int testTime=0,dispTime,pe12,pe14,pe15;
+
+void tipInt(void){plusF12=1;wait(0.0002);plusF12=0;}//plus width=0.00001S
+void PlusInE9(void){wait(0.0001f);if(PE_9)pe9++;}
+void PlusInF15(void){wait(0.0001f);if(PF_15)pf15++;}
+//Test leds
+void testLed(void){
+ if(testTime==0){led1=1;led3=0;testTime++;
+ }else if(testTime==1){led2=1;led1=0;testTime++;
+ }else if(testTime==2){led3=1;led2=0;testTime=0;}
+}
+//显示布局 6903
+void dispBase(void){
+ c2l(0,2,19);c2l(1,2,28);c2l(2,2,37);//JS=
+ c2l(0,3,10);c2l(1,3,0);c2l(2,3,37);c2l(8,3,10);c2l(9,3,1);c2l(10,3,37);//A0=,A1=
+ c2l(0,4,10);c2l(1,4,2);c2l(2,4,37);c2l(8,4,10);c2l(9,4,3);c2l(10,4,37);//A2=,A3=
+ c2l(0,5,25);c2l(1,5,22);c2l(2,5,0);c2l(3,5,37);//PM0
+ c2l(8,5,25);c2l(9,5,22);c2l(10,5,1);c2l(11,5,37);//PM1
+ c2l(0,6,25);c2l(1,6,22);c2l(2,6,2);c2l(3,6,37);//PM2
+ c2l(8,6,14);c2l(9,6,3);c2l(10,6,4);c2l(11,6,5);//P345
+ c2l(0,7,25);c2l(1,7,14);c2l(2,7,9);c2l(3,7,37);//PE9
+ c2l(8,7,25);c2l(9,7,15);c2l(10,7,1);c2l(11,7,5);c2l(12,7,37);//PF15
+ //c2l(5,0,25);c2l(5,1,42);c2l(5,2,18);c2l(5,3,24);//PJ28
+ //c2l(6,0,13);c2l(6,1,41);c2l(6,2,51);c2l(6,3,52);//dist
+}
+//Display Test Data 6903
+void dispMes(void){
+ c2l(3,2,(js/10000000)%10);c2l(4,2,(js/1000000)%10);c2l(5,2,(js/100000)%10);c2l(6,2,(js/10000)%10);
+ c2l(7,2,(js/1000)%10);c2l(8,2,(js/100)%10);c2l(9,2,(js/10)%10);c2l(10,2,(js)%10);
+ c2l(3,3,int(val0*10)%10);c2l(4,3,int(val0*100)%10);c2l(5,3,int(val0*1000)%10);c2l(6,3,int(val0*10000)%10);
+ c2l(11,3,int(val1*10)%10);c2l(12,3,int(val1*100)%10);c2l(13,3,int(val1*1000)%10);c2l(14,3,int(val1*10000)%10);
+ c2l(3,4,int(val2*10)%10);c2l(4,4,int(val2*100)%10);c2l(5,4,int(val2*1000)%10);c2l(6,4,int(val2*10000)%10);
+ c2l(11,4,int(val3*10)%10);c2l(12,4,int(val3*100)%10);c2l(13,4,int(val3*1000)%10);c2l(14,4,int(val3*10000)%10);
+ c2l(4,5,int(dut0*10)%10);c2l(5,5,int(dut0*100)%10);c2l(6,5,int(dut0*1000)%10);
+ c2l(12,5,int(dut1*10)%10);c2l(13,5,int(dut1*100)%10);c2l(14,5,int(dut1*1000)%10);
+ c2l(4,6,int(dut2*10)%10);c2l(5,6,int(dut2*100)%10);c2l(6,6,int(dut2*1000)%10);
+ c2l(13,6,(inPutE12&1)%1);c2l(14,6,(inPutE14&1)%1);c2l(15,6,(inPutE15&1)%1);
+ c2l(4,7,(pe9/100)%10);c2l(5,7,(pe9/10)%10);c2l(6,7,(pe9)%10);
+ c2l(13,7,(pf15/100)%10);c2l(14,7,(pf15/10)%10);c2l(15,7,(pf15)%10);
+ //c2l(6,5,int(dist/100)%10+16);c2l(6,6,int(dist/10)%10+16);c2l(6,7,int(dist)%10+16);c2l(6,8,14);c2l(6,9,int(dist*10)%10+16);c2l(6,10,int(dist*100)%10+16);
+}
+// main() runs in its own thread in the OS
+int main(){
+ pwm0.period(0.01);
+ pwm1.period(0.02);
+ pwm2.period(0.03);
+ inPutE12.mode(PullNone);
+ inPutE14.mode(PullNone);
+ inPutE15.mode(PullNone);
+ lcdInit();
+ lcdClear();
+ dispBase();
+ tick.attach(&tipInt,0.005);
+ plusInE9.rise(&PlusInE9);
+ plusInF15.rise(&PlusInF15);
+ while (true){
+  js++;
+  val0=adc0.read();
+  val1=adc1.read();
+  val2=adc2.read();
+  val3=adc3.read();
+  if(dut0>0.98f){pwmdir0=0;}if(dut0<0.03f){pwmdir0=1;}
+  if(pwmdir0==1){dut0 +=ddu0;pwm0=dut0;}
+  if(pwmdir0==0){dut0 -=ddu0;pwm0=dut0;}
+  if(dut1>0.97f){pwmdir1=0;}if(dut1<0.04f){pwmdir1=1;}
+  if(pwmdir1==1){dut1 +=ddu1;pwm1=dut1;}
+  if(pwmdir1==0){dut1 -=ddu1;pwm1=dut1;}
+  if(dut2>0.96f){pwmdir2=0;}if(dut2<0.05f){pwmdir2=1;}
+  if(pwmdir2==1){dut2 +=ddu2;pwm2=dut2;}
+  if(pwmdir2==0){dut2 -=ddu2;pwm2=dut2;}
+  pe13=gpio_read(inPutE12);//pe14=inPutE14.gpio_read();pe15=inPutE15.gpio_read();
+  if(dispTime>10){dispTime=0;dispMes();testLed();pe9=0;pf15=0;}
+  dispTime++;
+  wait(0.02);
+ }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Sun Jul 30 13:00:37 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#ed9d1da9dd0c43907ba40cba5ebd9f2c6da3dc07