1 1 TA, 20 10 6,9 1. (http://www.cyb.mei.titech.ac.jp/2008ss2/main.htm) 2. TM TM GUI TM 1. P7-13 TM Notepad, Meadow, ( P109 ). 2. (shisaku01/sys test) H src c startup ncrt0 ss2.a30 sect30 ss2.inc 1 1 / 11
, T 2.1 I/O 1 4 P1 5 P1 7 3 P6 8 P7 8 P8 0 P8 3 P8 5 P8 7 7 P9 0 P9 3 4 P10 8 38 P162 rjj09b0033 m16chm.pdf []-[P ]- [RENESAS-TOOLS]-[Document]-[ ] C:MTOOL/Document/HW 2.2 I/O I/O SFR sfr26.h #include "sfr26.h" // OAKSmini re unsigned char LED_out; unsigned int TGL_out; pd1 = 0x00; // 1 pd10 = 0x00; // 10 pd7 = 0x3f; // P7-6,7: // TGL_out = 0; if ( ( p10 & 0x80 ) == 0 ) { TGL_out = TGL_out + 1000; } if ( ( p10 & 0x40 ) == 0 ) { TGL_out = TGL_out + 100; } if ( ( p10 & 0x20 ) == 0 ) { TGL_out = TGL_out + 10; } if ( ( p10 & 0x10 ) == 0 ) { TGL_out = TGL_out + 1; } // LED LED_out = 0; if ( ( p1 & 0x80 ) == 0 ) { LED_out = LED_out 0x20; } if ( ( p1 & 0x40 ) == 0 ) { LED_out = LED_out 0x08; } if ( ( p1 & 0x20 ) == 0 ) { LED_out = LED_out 0x02; } p7 = LED_out; 1 2 / 11
& and or and 1 1 or 1 1 0 0 1 a=0x5555 & 0x00ff 0101 0101 0101 0101 (5555) and) 0000 0000 1111 1111 (00ff) a = 0000 0000 0101 0101 (0055) a=0x5555 0x00ff 0101 0101 0101 0101 (5555) or ) 0000 0000 1111 1111 (00ff) a = 0101 0101 1111 1111 (0055) short int a = 0xf00f; a= a << 1 1111 0000 0000 1111 (f00f) a = 1110 0000 0001 1110 (e01e) and 8 or 8 1 1 2.3 LCD MCU LCD Lyquid Crystal Display LCD LCDfunc.c LCD 1 3 / 11
#include <stdio.h>// sprintf() #include "LCDfunc.h" // LCD char buff[64]; // // LCD LCD_init(); // LCD LCD_cls(); // // LCD_locate( 0, 0, 0, 0 ); // (0,0) OFF // //sprintf //sprintf /* sprintf( buff, " %4d %4d %4d %4d %4d %04d ", ad2_result, ad1_result, ad0_result, count4, count3, TGL_out); LCD_print_str( buff ); // */ //itoa ---> nosprintf.c //itoa(integer to ascii : 10 ) /* itoa(buff, ad2_result,5); itoa_cat(buff, ad1_result,5); itoa_cat(buff, ad0_result,5); itoa_cat(buff, count4,6); itoa_cat(buff, count3,5); itoa_cat(buff, TGL_out,5); LCD_print_str( buff ); // */ //exc_itoa ---> nosprintf.c //exc_itoa : // //LCD 32 strcpy(buff," "); // //5 -> -123 exc_itoa(&buff[4],ad2_result); //10 ->1111 exc_itoa(&buff[9],ad1_result); // exc_itoa(&buff[14],ad0_result); exc_itoa(&buff[20],count4); exc_itoa(&buff[25],count3); exc_itoa(&buff[30],tgl_out); // buff -> " -123 1111 2222 3333 4444 5555 " 1 4 / 11
sprintf nosprintf.c nosprintf.c (10 ) itoa, itoa cat (16 ) htoa, htoa cat ftoa, ftoa cat cat 10 exc itoa nosprintf.c nosprintf.c LCD P9 PRCR PD9 LCD init() 1 5 / 11
3. (H/L) (0/1) 1 ( ) 4. ( ) ( ) 4.1 4.1.1 16 8 8 A 5 B 3 A CPU 0 PWM PWM D/A PWM 4.1.2 1 ( 1 ) 1 6 / 11
// void ta0int( void ); // #pragma INTERRUPT ta0int //50msec #define cnt_ta0 31250-1 // A0 void main( void ) { // udf = 0x00; // ta0mr = 0x80; // 1/32 //CPU 20MHz 32 20MHz/32=625KHz ta0 = cnt_ta0; // ta0ic = 0x06; // 7 tabsr = 0x01; // _asm( "\tfset I"); // } // void ta0int( void ) { } sect30 ss2.inc // void ta0int( void ); // #pragma INTERRUPT ta0int // void ta0int( void ) { // } 1 7 / 11
1. kadai0101 kadai0101.c 2. 0.1sec LED LED I/O rjj09b0033 m16chm.pdf P162 4.2 () INT0,1,3,4,5 5 4.2.1 // // void int3int( void ); // 3 #pragma INTERRUPT int3int // int3ic = 0x06; //bit2,1,0= 110 6 //bit4 = 0 _asm( "\tfset I"); // void int3int( void ) { // } 1 8 / 11
5. Fig. 1 ON 0 V OFF 5 V Fig. 2 1 5V 5V 10kΩ 22kΩ 47Ω 74HC14 + 1µF GND Fig. 1: GND Fig. 2: : Fig. 3 1 9 / 11
Fig. 3: よい例 Fig. 4: 悪い例 悪い例に関しては 回路全体の見通しも悪く 後で最終的な回路の完成図を起こすときにも面 倒になる 注意 ジャンパ線はきれいに使い たくさんあるからといってずさんな管理しない ジャンパ線の数はスタッフが整理 確認している 74HC14 使用時の留意点 Fig. 5: 74HC14 の外観 Vcc 14 13 12 11 10 9 8 1 2 3 4 5 6 7 GND Fig. 6: 74HC14 のピン配置 Fig. 5 のようにおいたとき ピン配置は Fig. 6 のようになります また使わない入力は GND と 接続しておくのがよい また 積層セラミックコンデンサ 104 0.1µF を Vcc と GND 間に接続 し 動作を安定化させる このような用途のコンデンサのことを バイパスコンデンサ という 5.1 端子台への接続 MCU ボード上には端子台が設置されており Fig. 7 のようなピン配置になっている P1-5,6,7 は外部割り込み関数の INT3,4,5 にそれぞれ対応しており P10-0 7 は A/D 変換が使用できるポー トに対応している 次のスイッチの課題ではこの端子台を用いるため 接続は十分注意して行う こと さらに 電解コンデンサ (1µF) には極性 ー があるので接続を間違えないように注意 すること 積層セラミックコンデンサには極性は存在しない 試作検討 1 10 / 11
Fig. 7: MCU 1. (Fig. 2) ON/OFF a 2. LCD Hint P.8 (P1-5,int3int ) MCU GND +5V P1-5 MCU MCU a,. 1 11 / 11