/*
* avr140.c
*
* 右ローテイト
*/
#include <avr/io.h>
#include "hd44780.h" // EZ-LCDインクルードファイル
void InitHard( void); // ポートの初期化
int main(void)
{
unsigned char a = 243;
unsigned char i, x, y, res;
InitHard(); // ポートの初期化をします。
lcd_init (); // LCDの初期化をします。
res = a;
for ( i = 0; i < 3; i++)
{
x = res << 7; // 7bit 右シフト
y = res >> 1; // 1bit 左シフト
res = x | y;
}
// LCDに元データ表示
lcd_locate( 0, 0); // 1行目
for ( i = 0; i < 8; i++)
{
x = ( a & 0x01) + 0x30;
lcd_putc( x); // LCDに表示
a = a >> 1;
}
// LCDに演算結果を表示
lcd_locate( 1, 0); // 2行目
for ( i = 0; i < 8; i++)
{
x = ( res & 0x01) + 0x30;
lcd_putc( x); // LCDに表示
res = res >> 1;
}
while(1)
{
//TODO:: Please write your application code
}
}
void InitHard( void) // ポートの初期化
{
// ポートB初期設定
DDRB = 0xff; // PB7~PB0を出力に設定します。
PORTB = 0; // PB7~PB0に'L'を出力します。
// ポートC初期設定
DDRC = 0x3f; // PC7,PC6は初期(入力)、PC5~PC0を出力に設定します。
PORTC = 0; // PC7~PC0に'L'を出力します。
// ポートD初期設定
DDRD = 0xf0; // PD7~PD4は出力、PD3~PD0は入力に設定します。
PORTD = 0; // PD7~PD0に'L'を出力します。
}