'잡동사니'에 해당되는 글 12635건

  1. 2013.12.20 cron / crontab
  2. 2013.12.20 lc1628 예제 소스
  3. 2013.12.20 Atmega8 으앙 쥬금!!! ㅠㅠ
  4. 2013.12.19 avr pud(pull up disable)
  5. 2013.12.19 AVR-GCC Program space
  6. 2013.12.19 ATmega128 BOOTSZ
  7. 2013.12.18 AVROSP
  8. 2013.12.18 AVR soft reset
  9. 2013.12.18 AVR Studio / avr-libc bootloader
  10. 2013.12.18 assert()
Linux2013. 12. 20. 23:33
아는 지인의 요청으로 검색하게 된 내용


crontab의 경우 시스템 전체와 사용자 별로 설정을 저장한다.
crontab [-u user] file
crontab [-u user] [-l | -r | -e] [-i] [-s]
 
[링크 : http://linux.die.net/man/1/crontab ] 

ubuntu 12.10 LTS에서 도움말을 보니 추가된 내용이 있는데
$ man crontab
FILES
       /etc/cron.allow
       /etc/cron.deny
       /var/spool/cron/crontabs

       There  is  one  file  for  each  user's  crontab under the /var/spool/cron/crontabs directory. Users are not
       allowed to edit the files under that directory directly to ensure that only users allowed by the  system  to
       run  periodic  tasks  can  add them, and only syntactically correct crontabs will be written there.  This is
       enforced by having the directory writable only by the crontab group and configuring crontab command with the
       setgid bid set for that specific group. 

/etc/crontab 은 system 전체에 대한 (데몬용) crontab이고
/var/spool/cron/crontabs/ 에는 사용자별 crontab 파일이 존재한다.

또한 cron에 대한 로그는
기본적으로
/var/log/syslog에서 "CRON" 키워드로 검색을 하면 나오지만 안나온다면
cron에서 실행되는 스크립트의 마지막에 로그를 남기도록 하는 수 밖에 없을듯 하다. 
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2013. 12. 20. 15:48
원래 링크의 카페는 막혀있어서
회로 구성이라던가 이런걸 알 수 없지만 참고용으로 링크 저장

데이터시트 상으로는 ns 급으로 쉬어주어야 하지만
AVR ATmega128 16MHz라고 해도
명령어 처리에 10ns 급 정도의 딜레이는 가볍게 생기니까
그런건 무시하고 바로바로 포트에 값을 넣어 주는 듯 하다.

[링크 : http://blog.daum.net/irobotavr/668278] 8bit 통신

4bit 통신예제. PORTB로 되어있음. 하지만.. 작동이 안되네?
// used pins on port B
#define LCD_DB4 0    // PORTB.0 
#define LCD_DB5 1    // PORTB.1
#define LCD_DB6 2    // PORTB.2 
#define LCD_DB7 3    // PORTB.3
#define LCD_E  6     // PORTB.6 Enable 
#define LCD_RS 7     // PORTB.7 Register Select
[링크 : http://www.avrprojects.net/.../avr-c-programming-tutorials/112-4-bit-lcd-interface] 4bit 통신


---
PORTC 에 
7654(DATA) 2(E) 1(RW) 0(RS) 로 회로가 구성된 경우로 포팅한 녀석.
이 소스는 문자가 무언가는 나오지만 제대로 나오지 않는 문제가 있다.
하지만 이 소스를 통해 CLCD를 초기화할 경우 제대로 되기에 초기화 부분을 분석해서 내 소스에 적용하게 됨.
// used pins on port B
#define LCD_DB4 4    // PORTB.0 
#define LCD_DB5 5    // PORTB.1
#define LCD_DB6 6    // PORTB.2 
#define LCD_DB7 7    // PORTB.3
#define LCD_E  2     // PORTB.6 Enable 
#define LCD_RS 0     // PORTB.7 Register Select


//LCD commands
#define LCD_CLR 		0x01    // clear display
#define LCD_HOME 		0x02    // return home

#define LCD_INC 		0x06    // Increment, display freeze
#define LCD_MOV 		0x10    // Cursor move, not shift

#define LCD_OFF         0x08    // lcd off
#define LCD_ON          0x0C    // lcd on             
#define LCD_BLINK_ON	0x0D    // blink on              
#define LCD_CURSOR_ON	0x0E    // cursor on               
#define LCD_ALL_ON	    0x0F    // cursor on /  blink on
#define LCD_LINE1  		0x80    // cursor Pos on line 1 (or with column)
#define LCD_LINE2  		0xC0    // cursor Pos on line 2 (or with column)

unsigned char chr,data,pos;

// writes a char to the LCD
void LCD_char(unsigned char data)

{
	PORTC = data & 0b11110000; //high nibble
	PORTC |= 1 << LCD_RS;
	PORTC |= 1 << LCD_E;
	_delay_ms(2);
	PORTC &= ~(1 << LCD_E);
	_delay_ms(2);

	PORTC = (data << 4) & 0b11110000; //low nibble
	PORTC |= 1 << LCD_RS;
	PORTC |= 1 << LCD_E;
	_delay_ms(2);
	PORTC &= ~(1 << LCD_E);
	_delay_ms(2);
}


// writes a instruction to the LCD
void LCD_inst(unsigned char inst)

{	
	PORTC = (inst & 0b11110000); //send high nibble
	PORTC &= ~(1 << LCD_RS); // set RS to instructions
	PORTC |= 1 << LCD_E;
	_delay_ms(2);
	PORTC &= ~(1 << LCD_E);
	_delay_ms(2);

	PORTC = (inst << 4) & 0b11110000; //send low nibble
	PORTC |= 1 << LCD_E;
	_delay_ms(2);
	PORTC &= ~(1 << LCD_E);
	_delay_ms(2);	
}

// clear display
void LCDclr(void)
{
	LCD_inst (LCD_CLR);
}

// return home
void LCDhome(void)
{
	LCD_inst (LCD_HOME);
}

// LCD off
void LCDoff(void)
{
	LCD_inst (LCD_OFF);
}

// LCD on
void LCDon(void)
{
	LCD_inst (LCD_ON);
}

// cursor on
void LCDcursor(void)
{
	LCD_inst (LCD_CURSOR_ON);
}

// blink on
void LCDblink(void)
{
	LCD_inst (LCD_BLINK_ON);
}

// cursor all on
void LCDall(void)
{
	LCD_inst (LCD_ALL_ON);
}

//go to first line
void LCDline1 (void)

{
	LCD_inst (0b10000000);
}

//go to second line
void LCDline2 (void)
{
	LCD_inst (0b11000000);
}


// goto position x,y
void LCDgoto (char x,char y)
{

	if (y == 0)			pos = 0b00000000 + x;
	else if (y == 1)	pos = 0b01000000 + x;

	LCD_inst (0b10000000 | pos);
}

//write text to the LCD
void LCDtext(char *data)
{
	while (*data)
	{
		LCD_char(*data);
		data++;
	}
}

// init LCD

void LCD_init(void)
{
	DDRC = 0xFF;  // PORTC as output
	_delay_ms(40);

	// set 4-bit mode
	PORTC = 1 << 2;
	PORTC |= 1 << LCD_E;
	_delay_ms(1);
	PORTC &= ~(1 << LCD_E);
	_delay_ms(1);

	PORTC = 1<< 2;
	PORTC |= 1 << LCD_E;
	_delay_ms(1);
	PORTC &= ~(1 << LCD_E);
	_delay_ms(1);

	PORTC = 1 << 2;
	PORTC |= 1 << LCD_E;
	_delay_ms(1);
	PORTC &= ~(1 << LCD_E);
	_delay_ms(1);

	//set 4-bit mode and 2-line
	//LCD_inst (0b00101000);
	LCD_inst (0b00101000);

	//turn on display and cursor
	LCD_inst (0b00001100);

	//clr display
	LCD_inst (LCD_CLR);
}

int main( void )
{
	LCD_init();
	LCDtext (">AVR LCD DEMO<");
	LCDgoto (2,1);
	LCDtext("Hello World!");
	LCDall();
	LCDhome();
}

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

ATmega128 + LC1628 제어하기 2  (0) 2013.12.24
ATmega128 + LC1628 제어하기 1  (0) 2013.12.24
Atmega8 으앙 쥬금!!! ㅠㅠ  (0) 2013.12.20
avr pud(pull up disable)  (0) 2013.12.19
AVR-GCC Program space  (0) 2013.12.19
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2013. 12. 20. 11:09
거상인의 Atmega8 보드의 기본값은 내부 RC 클럭 1MHz 이다.


그래서! 외부 16MHz 크리스탈로 바꾸려고 했는데!! 망했어요!!! ㅠㅠ
아무생각없이 외부 클럭이니까.. Ext. Clock 이면 될꺼야. 클릭.. 어.. 안읽히네?!?!?


그래서 부랴부랴
us-technology의 외부 16MHz 크리스탈 제품의 설정값을 읽어 보니 ㅠㅠ
"Ext. Crystal/Resonator"  ㅠㅠ

일단.. 현재 상태는.. External Clock이 된거 같은데.. 문제는 이상황에서는 크리스탈 발진이 되지 않기 때문에
오실레이터를 통해 클럭이 생성된걸 넣어 주어야 살아 난다!!! ㅠㅠ
결국은 클럭 소스를 만들어 줘야 하는 상황 ㅠㅠ 


흑흑 Atmega8의 TQFP 패키지는 이렇게 생겨 먹었고.. XTAL1에 클럭을 넣어줘야 하니..


저 핀에 점퍼를 날려서 하면 참.. 쉽죠? 가 될 거 같을.... 리가 있나!!! ㅠㅠ 망했어요!!!! ㅠㅠ


아 몰라.. 되다 안되다 해서 모르겟네..
일단 ATTINY2313 1개는 Ext Crystal로 갔다가 되돌렸는데
다시 시도해보니 연타로 3개 날려버림! ㅠㅠ

결론 : 망했어요 ㅠㅠ



인공호흡 방법
[링크 : http://turbocrazy.tistory.com/241]
[링크 : http://blog.naver.com/eom913/126826512]

Atmega8 데이터시트
[링크 : http://www.atmel.com/images/atmel-2486-8-bit-avr-microcontroller-atmega8_l_datasheet.pdf]

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

ATmega128 + LC1628 제어하기 1  (0) 2013.12.24
lc1628 예제 소스  (0) 2013.12.20
avr pud(pull up disable)  (0) 2013.12.19
AVR-GCC Program space  (0) 2013.12.19
ATmega128 BOOTSZ  (0) 2013.12.19
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2013. 12. 19. 14:31
예전 회사에서 작업중에
내부 풀업으로 인해 Tri-state로 되지 않아 I2C를 제대로 하지 못했던 기억이 있어 찾아 보니
PUD 설정 기본값은 0이 아닐까 싶다.
걍.. 덤프해볼까...


그리고 PUD 는 SFIOR 레지스터의 0x04 값으로 모든 포트와 모든 핀에 적용이 된다. 
특정 포트만 pull-up을 끌수가 없다는 거.. (alternative랑은 상관없으려나?) 

[링크 : http://www.atmel.com/Images/doc2467.pdf]


+ 2016.03.30

[링크 : http://kakkustudy.tistory.com/46]

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

lc1628 예제 소스  (0) 2013.12.20
Atmega8 으앙 쥬금!!! ㅠㅠ  (0) 2013.12.20
AVR-GCC Program space  (0) 2013.12.19
ATmega128 BOOTSZ  (0) 2013.12.19
AVROSP  (0) 2013.12.18
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2013. 12. 19. 11:32
어떻게 보면.. const 키워드랑 비슷한데

폰노이만 방식이 아닌 하버드 아키텍쳐의 특성상 분리된 주소 공간을 가지는 상황에서
플래시 저장된 데이터를 이용함으로서 SRAM의 공간을 확보하는 방법이다.

The AVR is a Harvard architecture processor, where Flash is used for the program, RAM is used for data, and they each have separate address spaces. It is a challenge to get constant data to be stored in the Program Space, and to retrieve that data to use it in the AVR application.

[링크 : http://www.nongnu.org/avr-libc/user-manual/pgmspace.html

그런 이유로.. gcc implement 상으로는
const 형으로 데이터를 저장하고
읽을때는 LPM(Load Program Memory) 어셈명령을 이용하여 읽게 된다.
#define PGM_P   const char *
#define pgm_read_byte_near (   address_short )    __LPM((uint16_t)(address_short))
 
[링크 : http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html]  

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

Atmega8 으앙 쥬금!!! ㅠㅠ  (0) 2013.12.20
avr pud(pull up disable)  (0) 2013.12.19
ATmega128 BOOTSZ  (0) 2013.12.19
AVROSP  (0) 2013.12.18
AVR soft reset  (0) 2013.12.18
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2013. 12. 19. 10:05
부트로더 사이즈의 약자인거 같은데
부트로더를 사용하기 위해서는 퓨즈 비트도 변경되어야 하고 추가로 부트 영역의 크기를 지정할 수 있게 된다.
Atmega64와 Atmega128은 플래시 크기가 달라서 아래 표기되는 start address의 값이 달라진다.


BOOTSZ - 부트로더의 크기를 설정함
BOOTRST - 0x0000 이 아닌 부트로더 영역에서 시작하도록 함


 If a Boot Loader is implemented, it can be called either directly from the Application code using calls or jumps, or by programming the BOOTRST Fuse. When the BOOTRST Fuse is programmed, the CPU will start execution in the Boot Loader section on Reset, instead of starting at address 0. The BOOTRST Fuse can be changed using Serial or Parallel Programming.
 

[링크 : http://www.atmel.com/images/doc1644.pdf]


LB는 전체에 대한 메모리 보호를 하지만


BLB0프로그램에서 부트로더 영역을 읽고 쓰지 못하도록 하고 
BLB1부트로더에서 부트로더 영역을 읽거나 쓰지 못하도록 하는 설정이다(자체 보호 기능)


Boot Lock Modes (BLB)
Store Program Memory (SPM)

[링크 : http://www.atmel.com/images/doc1644.pdf] 


Load Program Memory (LPM)
[링크 : http://www.atmel.com/Images/doc1233.pdf]

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

avr pud(pull up disable)  (0) 2013.12.19
AVR-GCC Program space  (0) 2013.12.19
AVROSP  (0) 2013.12.18
AVR soft reset  (0) 2013.12.18
AVR Studio / avr-libc bootloader  (0) 2013.12.18
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2013. 12. 18. 18:32
만든데가 사라졌나.. 은근 구하기 힘드네..
AVR 부트로더를 이용한 AVR 업로드 프로그램이다.



[링크 : https://code.google.com/p/nsk-embedded-downloads/]

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

AVR-GCC Program space  (0) 2013.12.19
ATmega128 BOOTSZ  (0) 2013.12.19
AVR soft reset  (0) 2013.12.18
AVR Studio / avr-libc bootloader  (0) 2013.12.18
COM26T2844VTX LCD 데이터 시트  (0) 2013.07.23
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2013. 12. 18. 14:28
결국(?)은 와치독을 이용해서 리셋 시키는 것 외에는 없는걸려나?

[링크 : http://support.atmel.com/bin/customer.exe?=&action=viewKbEntry&id=21]
[링크 : http://bomoolchanggo.blogspot.kr/2009/10/avr-atmega128-software-reset.html]

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

ATmega128 BOOTSZ  (0) 2013.12.19
AVROSP  (0) 2013.12.18
AVR Studio / avr-libc bootloader  (0) 2013.12.18
COM26T2844VTX LCD 데이터 시트  (0) 2013.07.23
ST-23G / EL-23G 가지고 놀기  (0) 2013.07.07
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2013. 12. 18. 13:23
AVR Studio 도움말을 보니.. 섹션을 나누어서 부트로더로 할당이 가능하다는데...
자세한건 조금더 찾아 봐야겠네...

Select the Memory Type, name and address for the new segment and press Ok.

To specify a bootloader for example, set memory type to "Flash", give the bootloader a name and specify one of the allowed addresses for a bootloader on the current part. It is recommended to use .bootloader as name for bootloaders. It has become more or less a standard and avr-libc supports this by providing a macro BOOTLOADER_SECTION that can be put in front of a function to put that function into the section named .bootloader. (defined in <avr/boot.h>).

The address must be given as a hexadecimal number prefixed with 0x. It is interpreted as a word address for flash memory and as byte addresses for sram and eeprom memory.



이런 예제파일이 있는데 거의다 어셈블리 매크로.. ㄷㄷㄷ


[링크 : http://www.realsys.co.kr/lecture/avr_bootloader.pdf]
[링크 : http://radmoon.egloos.com/1023318]

[링크 : http://www.engineersgarage.com/.../How-To-Write-a-Simple-Bootloader-For-AVR-In-C-language] 가입필요
[링크 : http://ranken.blog.me/20073963060]
[링크 : http://ranken.blog.me/20071841061] AVR109 SELF PROGRAMING 번역

[링크 : http://blog.schicks.net/wp-content/uploads/2009/09/bootloader_faq.pdf ]
[링크 : http://www.atmel.com/images/doc1644.pdf] AVR109 SELF PROGRAMING

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

AVROSP  (0) 2013.12.18
AVR soft reset  (0) 2013.12.18
COM26T2844VTX LCD 데이터 시트  (0) 2013.07.23
ST-23G / EL-23G 가지고 놀기  (0) 2013.07.07
IR LED 수광부 ST-23G를 이용한 장난질  (2) 2013.07.04
Posted by 구차니
Programming/C Win32 MFC2013. 12. 18. 01:55
한번쯤은 써봐야지하는 것 중에 하나
가장 강력하고 원초적인 디버깅 중에 하나로 printf()가 있다면
꽤나 상큼하고 스마트한 방법이라는데

assert()에서 비교문이 false 일 경우 강제종료 + 덤프를 한다고 한다.
일단 C/C++ 다 지원하는 듯..

NDEBUG가 정의되면 assert() 가 수행되지도 컴파일 되지도 않는다고 한다.
 #define NDEBUG // disable assert() calls

#include <assert.h>
void assert(scalar expression);
[링크 : http://linux.die.net/man/3/assert

[링크 : http://forum.falinux.com/zbxe/index.php?document_srl=408376&mid=C_LIB]
[링크 : http://www.cplusplus.com/reference/cassert/assert/]


---
2013.12.19
//#include <assert.h>
로 주석처리 하고 assert()를 부르면 컴파일 부터 배짼다 -_-
$ gcc c.c
/tmp/ccpSwySM.o: In function `main':
c.c:(.text+0x11): undefined reference to `assert'
collect2: ld returned 1 exit status 

#include "stdio.h"
#include "assert.h"

int main()
{
        assert(0);

        return 0;
}

음.. 우분투 12.04 LTS desktop에서 코어 덤프를 안하도록 해놔서 그런가..
덤프 파일이 생성되진 않았다.
$ gcc c.c
/tmp/ccpSwySM.o: In function `main':
c.c:(.text+0x11): undefined reference to `assert'
collect2: ld returned 1 exit status 

'Programming > C Win32 MFC' 카테고리의 다른 글

typeof  (0) 2014.03.11
const / pointer  (0) 2014.02.25
printf의 %s와 %S  (0) 2013.06.15
win32api - joystick 예제  (0) 2013.06.15
Windows IME  (0) 2013.02.14
Posted by 구차니