AnsweredAssumed Answered

Troubles about operating the main function of STM32F103C8T6

Question asked by ling.letters on Apr 10, 2017
Latest reply on Apr 14, 2017 by ling.letters

Hello~all,thanks for reading my thread.I met some troubles in the process of operating STM32F103C8T6,here this is the STM32F103C8T6's datasheet. does anyone here can help me out?

The program is as following:

 

            while (1)

                {

                        if(flag==0x01)

                        {

                                flag=0;//标志位清0

                                iPose=0;

                                USART1_Printf("123456789");

                                memcpy(&XY2_position,Receie_data,9);

                                if(XY2_position.num)Line_Bresenham(XY2_position.x0,XY2_position.y0,XY2_position.x1,XY2_position.y1);

                                else                      Line_DDA(XY2_position.x0,XY2_position.y0,XY2_position.x1,XY2_position.y1);

                        }

                }

}

void USART1_IRQHandler(void)        //串口1中断函数

{

        USART_ClearFlag(USART1,USART_FLAG_TC);

        if(USART1->SR & 0x00000020)//检查指定的USART中断发生与否

        {

                Receie_data[iPose]=USART1->DR & (uint16_t)0x01FF;//读取接收到的数据

                iPose++;//计数器加1

                if(iPose==9)flag=0x01;                

                USART1->DR = (flag & (uint16_t)0x01FF);

                while((USART1->SR&0x00000040) == 0);//准备发送一个数据        

        }

}

When I operated the program in the STM32,the reactive data which were reviewed shows normal.However,It always cant review that flag==1.Whats odd,the ninth digital of reactive data from series shows flag=1. According to its situation,I change another SCM to have a try,its normal in the first programming while there always display that the flag=1 from the second time.

Why? How to solve this problems? Please help me !

Thank you in advance!

Outcomes