c언어 질문입니다.

익명 사용자의 이미지

   while(1)
  {
 
                while(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET);//polling 방식  전송이 완료되면 usart_flag_txe는 set(즉, 1)이 된다. set이 된 후에는 reset을 해줘야 한다.
                ch = USART_ReceiveData(USART3);       
 
                int i=0;
 
                if(ch=='$'){
                  GPS_DATA[0]='$';            
                  GPScnt=1;
                  GPSflag=0;
                }
                else{
                  GPS_DATA[GPScnt]=ch;               
                  if(GPS_DATA[GPScnt]==0x0a){                                   // 위에서 ETX = 0x0A 라고 했으므로  조건을 걸어버린다.
                                 GPScnt1=GPScnt;                                    // 조건이 성립되면 COUNT 된 값을 GPScnt1으로 피신시킨다.  
                        if(strncmp(NAME,GPS_DATA,6)==0)  {           //  이 부분은 NAME = "$GPGGA" 비교한 것이다.  
                                        memcpy(GPS_DATA1,GPS_DATA,GPScnt1);     // 메모리 복사                                       
                                        GPS_cut= strtok(GPS_DATA1,",");                   // STRTOK 구간 나누는 함수                  
                                        while (GPS_cut!= null)               // 자른 문자열이 나오지 않을 때까지 반복
                                        {                                                
                                          GPS_cut = strtok(null, ",");      // 다음 문자열을 잘라서 포인터를 반환
                                          ++i;
                                          GPS_Dcut[i]=GPS_cut;
 
                                         }
                                         GPSflag=1; 
                                        unsigned char HH,MM,SS;                                                      // 시, 분, 초 저장 변수
                                        unsigned long Zulu_time;                                                       // GPS_TIEM(USA) 저장 변수  
 
                                         Zulu_time=atol(GPS_Dcut[1]);                                            // 문자열을 LONG 형 으로 변환 후 저장 =>" 035155.00 "
                                         HH=((Zulu_time/10000)+9);                                              // 만으로 나눈뒤 +9 로 한국 시 표현
                                         MM=((Zulu_time%10000)/100);                                          // 만 나머지 값에 100 나누어 준다. 분 표현
                                         SS=((Zulu_time%10000)%100);                                           // 만 나머지 값에 백 나머지 값으로 초 표현
                                         if(HH>23) HH-=24;                                                        // 한국은 +9시간 더해 주므로 오버되는 시간을 정정한다.
                                         printf("kkkkk%02d:%02d:%02d \n\r",HH,MM,SS);               // PRINTF 로 시 분 초 를 표현한다.  터미널     z       
 
 
 
 
                        }   
 
                        if(strncmp(NAME2,GPS_DATA,6)==0) {              //  이 부분은 NAME = "$GPRMC" 비교한 것이다.  
                                        memmove(GPS_DATA3,GPS_DATA,GPScnt1);
                                        GPS_cut= strtok(GPS_DATA3,",");                
                                       while (GPS_cut!= null)               // 자른 문자열이 나오지 않을 때까지 반복
                                        {     
                                         // printf("%s\n\n",GPS_cut);
                                          GPS_cut = strtok(null, ",");      // 다음 문자열을 잘라서 포인터를 반환
                                          ++i;
                                          GPS_Dcut2[i]=GPS_cut;
 
 
                                         }
                                       double speed;                                                                            // 속도 저장 변수
                                       double Knots;                                                                             // GPS_speed 저
                                       Knots = atof(GPS_Dcut2[7]);                                                    //문자열을 DOUBLE 형 으로 변환후 저장 => " 0.224 " 
                                       speed    = Knots * 1.8;                                                          // 속도 계산을 위하여 1.8을 곱한다.
                                       printf("kkkkjjjjjj%0.02lf\n\r",speed); 
 
 
 
                        }
 
 
 
 
                  } 
                  GPScnt++;
 
 
    }  
 
  }
 
}
 
 

void main(void)
{
RCC_Configuration();
NVIC_Configuration();
GPIO_Configuration();
TIM4_Configuration();
RCC_GetClocksFreq(&rcc_clocks);
USART1_Init(); 
USART3_Init();
 
draw_number(0,0,1);
draw_number(4,0,1);
draw_number(8,0,2);
draw_number(12,0,0);
 
while(1)
{
dot_display();
Time();
}
}

전체 코드중 문제있는 부분만 올려봤습니다.
코드에서 while(1)문이 2번사용되어 dot와 gps가 동시에 작동되지않네요ㅣ,,,,
방법좀알려주세요ㅜ

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.