SDA신호 출력을 오실로스코프로 확인하려고 하는데요. 파형이 안찍히네요.
현재 2410보드를 사용하고 있으며 이솝 게시판의 2.6.13커널을 이용하여 device driver에서 i2c를 set하여
커널 부팅시 다음과 같은 디버그 메세지를 확인하였습니다.
i2c /dev entries driver
s3c2410-i2c s3c2410-i2c: slave address 0x10
s3c2410-i2c s3c2410-i2c: bus frequency set to 99 KHz
s3c2410-i2c s3c2410-i2c: i2c-0: S3C I2C adapter
또한, /dev/i2c-0 장치 파일을 확인하였고 이 장치를 열어서 간단하게 명령어를 날리는 어플리케이션 코드를 작성하였습니다.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/poll.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
unsigned char command[1] = {0x55};
int main(int argc, char **argv)
{
char filename[20];
int file, i;
unsigned char addr = 0x86>>1; //slave의 주소를 셋팅하고,
sprintf(filename, "/dev/i2c-0");
//장치파일을 열고,
if( (file = open(filename, O_RDWR) ) < 0 )
{
printf("File Open Errorn");
exit(1);
}
else
printf("File Open Successn");
//slave 주소 셋팅하고,
if( ioctl(file, I2C_SLAVE, addr) < 0 )
{
printf("Error : Slave Address...n");
exit(1);
}
else
printf("Success : Slave Address...n");
printf("nSlave address : %xn", addr);
//0x55명령을 1초간격으로 100번 날린다.
for(i = 0; i < 100; i++)
{
write(file, command, 1);
printf("i : %d, command : %xn", i, command[0]);
sleep(1);
}
}
정말 간단한 어플리케이션인데요.
오실로 스코프로 SDA를 측정하면 제 예상대로라면 최초 start 비트 후에 SCL클럭핀에서 클럭이 계속 나와야 하고, SDA핀에서는 0x86>>1이므로 0100 0110에서 0010 0011로 시프트된후 MSB부터 7bit가 출력되고 write신호이므로 최종 SDA핀에서는 0010 0010 신호가 나간뒤 ack신호가 출력해야 할듯 하나 SDA에서 어떤 신호도 잡히고 있지 않습니다.
혹시 디바이스 드라이버 단에서 뭐를 더 손봐줘야 할게 있을까요? ^^;;
설 연휴 잘 쉬시고 새해 복 많이 받으세요~~