ST UART데이터 출력

msj153의 이미지

안녕하세요. ST-UART로 1-D 어레이 68개의 데이터를 하드웨어로 전송해서 모터 제어하는 프로그램을 짜고 있는데요. 데이터가 분명 출력이 되고 있는데 모터가 돌지를 않습니다. 같은 데이터를 avr에서 코딩했을때는 모터가 잘 도는데 arm에서 하니 않됩니다. 코딩은 다음과 같습니다.

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define BAUDRATE B1000000

#define BTUARTDEVICE "/dev/ttyS1"
#define _POSIX_SOURCE 1 /* POSIX 호환 소스 */

#define FALSE 0
#define TRUE 1

#define Array_size_read 2
#define Array_size_write 68

unsigned int size = sizeof(char);
int dev;
typedef unsigned char byte;

byte rxbuffer[Array_size_write];

int sock;
int conn;
int err;
char cmd;

static int debug_mode=0;
struct sockaddr_in address;
size_t addrLength = sizeof (struct sockaddr_in);

struct termios oldtio, newtio;
int monitoring_mode = 0;

void set(void){

int count;
int i;
char check=0;

rxbuffer[0]=0xff;
rxbuffer[1]=0xff;
rxbuffer[2]=0xfe;
rxbuffer[3]=0x40; //data length
rxbuffer[4]=0x83; //sync write
rxbuffer[5]=0x1e; // data 시작 adress position
rxbuffer[6]=0x04; // data 길이

rxbuffer[7]=0x00;
rxbuffer[8]=0x50;
rxbuffer[9]=0x01;
rxbuffer[10]=0x50;
rxbuffer[11]=0x01;

rxbuffer[12]=0x01;
rxbuffer[13]=0x50;
rxbuffer[14]=0x01;
rxbuffer[15]=0x50;
rxbuffer[16]=0x01;

rxbuffer[17]=0x02;
rxbuffer[18]=0x50;
rxbuffer[19]=0x01;
rxbuffer[20]=0x50;
rxbuffer[21]=0x01;

rxbuffer[22]=0x03;
rxbuffer[23]=0x50;
rxbuffer[24]=0x01;
rxbuffer[25]=0x50;
rxbuffer[26]=0x01;

rxbuffer[27]=0x04;
rxbuffer[28]=0x50;
rxbuffer[29]=0x01;
rxbuffer[30]=0x50;
rxbuffer[31]=0x01;

rxbuffer[32]=0x05;
rxbuffer[33]=0x50;
rxbuffer[34]=0x01;
rxbuffer[35]=0x50;
rxbuffer[36]=0x01;

rxbuffer[37]=0x06;
rxbuffer[38]=0x50;
rxbuffer[39]=0x01;
rxbuffer[40]=0x50;
rxbuffer[41]=0x01;

rxbuffer[42]=0x07;
rxbuffer[43]=0x50;
rxbuffer[44]=0x01;
rxbuffer[45]=0x50;
rxbuffer[46]=0x01;

rxbuffer[47]=0x08;
rxbuffer[48]=0x50;
rxbuffer[49]=0x01;
rxbuffer[50]=0x50;
rxbuffer[51]=0x01;

rxbuffer[52]=0x09;
rxbuffer[53]=0x50;
rxbuffer[54]=0x01;
rxbuffer[55]=0x50;
rxbuffer[56]=0x01;

rxbuffer[57]=0x0a;
rxbuffer[58]=0x50;
rxbuffer[59]=0x01;
rxbuffer[60]=0x50;
rxbuffer[61]=0x01;

rxbuffer[62]=0x0b;
rxbuffer[63]=0x50;
rxbuffer[64]=0x01;
rxbuffer[65]=0x50;
rxbuffer[66]=0x01;

for(i=2;i<67;i++){
check= check+rxbuffer[i];
}

rxbuffer[67]= ~(check);

}

static void exit_motor_server(int val){

int is_err = 0;
int ch;

ch = 1; // '1'는 하드웨어를 종료시킬때의 데이터라고 가정.
write(dev,&ch,1); //BT-uart시리얼에 데이터를 보낸다.
printf("return to old termios\n");

tcsetattr( dev, TCSANOW, &oldtio );
if((errno = close(dev))<0){
perror("close");
printf("errno :: %d\n",errno);
is_err = 1;
}else{
printf("DEVICE file close success..\n");
}

if((errno = close(sock))<0){
perror("close");
printf("errno :: %d\n",errno);
is_err = 1;
}else{
printf("SOCKET close success..\n");
}

if(!is_err)
exit(1);
}

void init_terminal(void){

fd_set readset;
dev= open( BTUARTDEVICE, O_RDWR | O_NOCTTY );
if ( dev < 0 ) {
perror( BTUARTDEVICE );
exit(-1);
}

tcgetattr( dev, &oldtio ); /* save current serial port settings */
bzero( &newtio, sizeof( newtio ) ); /* clear struct for new port settings */


newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;


newtio.c_cc[VINTR] = 0; /* Ctrl-c */
newtio.c_cc[VQUIT] = 0; /* Ctrl-\ */
newtio.c_cc[VERASE] = 0; /* del */
newtio.c_cc[VKILL] = 0; /* @ */
newtio.c_cc[VEOF] = 4; /* Ctrl-d */
newtio.c_cc[VTIME] = 0; /* inter-character timer unused */
newtio.c_cc[VMIN] = 1; /* blocking read until 1 character arrives */
newtio.c_cc[VSWTC] = 0; /* '\0' */
newtio.c_cc[VSTART] = 0; /* Ctrl-q */
newtio.c_cc[VSTOP] = 0; /* Ctrl-s */
newtio.c_cc[VSUSP] = 0; /* Ctrl-z */
newtio.c_cc[VEOL] = 0; /* '\0' */
newtio.c_cc[VREPRINT] = 0; /* Ctrl-r */
newtio.c_cc[VDISCARD] = 0; /* Ctrl-u */
newtio.c_cc[VWERASE] = 0; /* Ctrl-w */
newtio.c_cc[VLNEXT] = 0; /* Ctrl-v */
newtio.c_cc[VEOL2] = 0; /* '\0' */

tcflush( dev, TCIFLUSH );
if(tcsetattr( dev, TCSANOW, &newtio ) != 0){
printf("BTUART tcsetattr() error\n");
exit_motor_server(0);
}
}

int main(void)
{
init_terminal();

signal(SIGINT, exit_motor_server);
signal(SIGTERM, exit_motor_server);
signal(SIGHUP, exit_motor_server);
signal(SIGKILL, exit_motor_server);

int tmp;

while(1)
{
set();

write(dev,rxbuffer,size*Array_size_write);

}

return 0;

}

제가 사용하고 있는 보드는 pxa270a 하이버스 보드이고요.
모터에서는 보레이트 1M, 8비트데이터, 1비트 스탑비트, no paritty, 비동기식 데이터를 전송받아야 합니다. 위의 조건들은 모두 만족 시키는 것같은데, ST-UART는 비동기식 출력이 맞는지는 확실히 모르겠습니다. 위조건들이 맞고 하면, 모터가 돌아야 하는데 모터가 돌지 않는 이유를 잘 모르겠습니다. 혹시 이상한 점이 있는지 알려주시면 감사하겠습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.