SIM908 Aynı Anda İki Port Çalışmıyor

Başlatan kimlenbu, 27 Mayıs 2014, 10:40:26

kimlenbu

Selamlar,

Bu modülü adam gibi çalışır hale getirene kadar rahatsız edeceğim :)

Bu GSM GPS modülünde komutları GMS MAIN adındaki 57600bps'de haberleşen porttan gönderiyorsunuz. GPS verisi ise GSM DEBUG adındaki 115200bps'de haberleşen porttan geliyor.

Modülün iki portunu da USB-Seri çevirici ile PC'ye bağlayınca sıkıntı yok. Komut gönderebiliyorum, GPS verisini alabiliyorum.

Modülün GPS verisi almak için olan GSM DEBUG portunu STM32F4 Discovery'e bağlayınca (USART1'de PB6:TX PB7:RX) gps verilerini alıp ayrıştırabiliyorum.

Komut göndermek için ise USART6'yı kullanıyorum (PC6:TX PC7:RX) yalnız ne zaman modülün komut aldığı GSM MAIN portuna USART6'yı bağlasam gps verisi alımı duruyor ve komut da gönderemiyorum. USART6'yı modüle değil de PC'ye bağlıyorum, bu sefer sorun yok, gps verisi akmaya devam ediyor, ve PC'ye komutlar doğru gidiyor.

İletişimde araya MAX3232 koydum gene değişen bir şey yok...

2 günümü yedi, ufak da olsa fikrinizi paylaşırsanız sevinirim.



USART init ve kesme kodları aşağıda :

void USART1_Conf(void)
{
  GPIO_InitTypeDef GPIO_InitStructure; // this is for the GPIO pins used as TX and RX
	USART_InitTypeDef USART_InitStructure;  // this is for the USART1 initilization
	NVIC_InitTypeDef NVIC_InitStructure; // this is used to configure the NVIC (nested vector interrupt controller)
	
	/* enable APB2 peripheral clock for USART1
	 * note that only USART1 and USART6 are connected to APB2
	 * the other USARTs are connected to APB1
	 */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
	
		/* enable the peripheral clock for the pins used by
	 * USART1, PB6 for TX and PB7 for RX
	 */
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
	
	/* This sequence sets up the TX and RX pins
	 * so they work correctly with the USART1 peripheral
	 */
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; // Pins 6 (TX) and 7 (RX) are used
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 			// the pins are configured as alternate function so the USART peripheral has access to them
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;		// this defines the IO speed and has nothing to do with the baudrate!
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;			// this defines the output type as push pull mode (as opposed to open drain)
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;			// this activates the pullup resistors on the IO pins
	GPIO_Init(GPIOB, &GPIO_InitStructure);					// now all the values are passed to the GPIO_Init() function which sets the GPIO registers
	
		/* The RX and TX pins are now connected to their AF
	 * so that the USART1 can take over control of the
	 * pins
	 */
	GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1); //
	GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1);
	
	/* Now the USART_InitStruct is used to define the
	 * properties of USART1
	 */
	USART_InitStructure.USART_BaudRate = 115200;				// the baudrate is set to the value we passed into this init function
	USART_InitStructure.USART_WordLength = USART_WordLength_8b;// we want the data frame size to be 8 bits (standard)
	USART_InitStructure.USART_StopBits = USART_StopBits_1;		// we want 1 stop bit (standard)
	USART_InitStructure.USART_Parity = USART_Parity_No;		// we don't want a parity bit (standard)
	USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // we don't want flow control (standard)
	USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; // we want to enable the transmitter and the receiver
	USART_Init(USART1, &USART_InitStructure);					// again all the properties are passed to the USART_Init function which takes care of all the bit setting
	
		/* Here the USART1 receive interrupt is enabled
	 * and the interrupt controller is configured
	 * to jump to the USART1_IRQHandler() function
	 * if the USART1 receive interrupt occurs
	 */
	USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); // enable the USART1 receive interrupt

	NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;		 // we want to configure the USART1 interrupts
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// this sets the priority group of the USART1 interrupts
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;		 // this sets the subpriority inside the group
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;			 // the USART1 interrupts are globally enabled
	NVIC_Init(&NVIC_InitStructure);							 // the properties are passed to the NVIC_Init function which takes care of the low level stuff

	// finally this enables the complete USART1 peripheral
	USART_Cmd(USART1, ENABLE);
}

void USART6_Conf(void)
{
  GPIO_InitTypeDef GPIO_InitStructure; // this is for the GPIO pins used as TX and RX
	USART_InitTypeDef USART_InitStructure;  // this is for the USART1 initilization
	NVIC_InitTypeDef NVIC_InitStructure; // this is used to configure the NVIC (nested vector interrupt controller)
	
	/* enable APB2 peripheral clock for USART1
	 * note that only USART1 and USART6 are connected to APB2
	 * the other USARTs are connected to APB1
	 */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
	
		/* enable the peripheral clock for the pins used by
	 * USART1, PB6 for TX and PB7 for RX
	 */
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
	
	/* This sequence sets up the TX and RX pins
	 * so they work correctly with the USART1 peripheral
	 */
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; // Pins 6 (TX) and 7 (RX) are used
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 			// the pins are configured as alternate function so the USART peripheral has access to them
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;		// this defines the IO speed and has nothing to do with the baudrate!
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;			// this defines the output type as push pull mode (as opposed to open drain)
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;			// this activates the pullup resistors on the IO pins
	GPIO_Init(GPIOC, &GPIO_InitStructure);					// now all the values are passed to the GPIO_Init() function which sets the GPIO registers
	
		/* The RX and TX pins are now connected to their AF
	 * so that the USART1 can take over control of the
	 * pins
	 */
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_USART6); //
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_USART6);
	
	/* Now the USART_InitStruct is used to define the
	 * properties of USART1
	 */
	USART_InitStructure.USART_BaudRate = 57600;				// the baudrate is set to the value we passed into this init function
	USART_InitStructure.USART_WordLength = USART_WordLength_8b;// we want the data frame size to be 8 bits (standard)
	USART_InitStructure.USART_StopBits = USART_StopBits_1;		// we want 1 stop bit (standard)
	USART_InitStructure.USART_Parity = USART_Parity_No;		// we don't want a parity bit (standard)
	USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // we don't want flow control (standard)
	USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; // we want to enable the transmitter and the receiver
	USART_Init(USART6, &USART_InitStructure);					// again all the properties are passed to the USART_Init function which takes care of all the bit setting
	
		/* Here the USART1 receive interrupt is enabled
	 * and the interrupt controller is configured
	 * to jump to the USART1_IRQHandler() function
	 * if the USART1 receive interrupt occurs
	 */
	USART_ITConfig(USART6, USART_IT_RXNE, ENABLE); // enable the USART1 receive interrupt

	NVIC_InitStructure.NVIC_IRQChannel = USART6_IRQn;		 // we want to configure the USART1 interrupts
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// this sets the priority group of the USART1 interrupts
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;		 // this sets the subpriority inside the group
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;			 // the USART1 interrupts are globally enabled
	NVIC_Init(&NVIC_InitStructure);							 // the properties are passed to the NVIC_Init function which takes care of the low level stuff

	// finally this enables the complete USART1 peripheral
	USART_Cmd(USART6, ENABLE);
}



void USART1_IRQHandler(void){

	// check if the USART1 receive interrupt flag was set
	if( USART_GetITStatus(USART1, USART_IT_RXNE) ){

		static uint8_t cnt = 0; // this counter is used to determine the string length
		static uint8_t DolarBulundu=0;
		static uint8_t SatirSonuBulundu=0;
		uint8_t verino=0;
		uint8_t satir=0;
		char t = USART1->DR; // the character from the USART1 data register is saved in t

		if (t=='$'){DolarBulundu=1;}
		else if (t=='\n'){SatirSonuBulundu=1;}
		
		if(DolarBulundu==1 && SatirSonuBulundu==0)
		{
			tmpStr100[cnt] = t;
			cnt++;
		}
		else if (SatirSonuBulundu==1)
		{ 
			cnt = 0;
			DolarBulundu=0;
			SatirSonuBulundu=0;
			GPSVerisiAyir();
		}
	}
}

void USART6_IRQHandler(void){

	// check if the USART1 receive interrupt flag was set
	if( USART_GetITStatus(USART6, USART_IT_RXNE) ){

		static uint8_t cnt6 = 0; // this counter is used to determine the string length
		char t = USART6->DR; // the character from the USART1 data register is saved in t

		/* check if the received character is not the LF character (used to determine end of string)
		 * or the if the maximum string length has been been reached
		 */
		if(t != '\n' && t!=';'){
			received_string2[cnt6] = t;
			cnt6++;
		}
		else{ // otherwise reset the character counter and print the received string
			cnt6 = 0;
			SSD1963_LCD_ShowString(395,378,received_string2,BEYAZ,BILGIRENGI,&Font16x24);
// 			USART_puts(USART1, received_string);
		}
	}
}

ali.bayuk

merhaba,
sim908i şuan bir projemde kullanıyorum ama sizin dediğiniz gibi bir problemle karşılaşmadım. ben PIC kullanıyorum devrede. fakat kullanan bir arkadaşımın haberleşme sorunu vardı ona biraz benziyor yaşadığınız durum. o hiç haberleşemiyordu mikrodeneyleyiciye bağladığında, daha sonra farketmişki datasheetinde tx-rx pinleri gerilim seviyesi 2.8v olmalıymış bizimkisi 3.8v veriyormuş. level-converter yapmış araya ve düzelmiş sorunu. kit olarak hiç kullanmadım sim908i ama belki böyle bir sorun olmuş olabilir. yardımcı olur mu bilmem ama söyleyeyim dedim :)