Ejemplo n.º 1
0
void main (void)
{
    TRISC0=0;   // Led Amar
    TRISC1=0;   // Led Verd
    TRISC2=0;   // LED Verm
    TRISC6=0;   // saida TX EUSART
    ADCON1=0x0F;    // coloca pinos I/O em modo digital (nao analogico)

    acordar();

    unsigned int D0, D1, D2, D3, minAnterior, contador, segInicial;
    char msg[30];

    LED_VERM=1;
     // inicia porta serial com 9600 bps @ 8mhz

    initExt7SegLCD();   // inicia barramento I2C e escreve ".12:34."
    pausa(1); piscaSeg(0);

    // Inicio do Relogio e Display

    contador=0;    // o contador esta acima do limite (59)
    minAnterior=10; // o minuto nunca chegaria a 10 (forca display)

    while (1)
    {

        
        getDS1307();

        sprintf(msg," _[%x:%x:%x]_", hora, minuto, segundo );
            while(BusyUSART());
            putsUSART( msg );

        D0 = (hora & 0b00110000) >> 4;  // utiliza somente 2 bits da nibble esq
        D1 = hora & 0b00001111;         // utiliza somente 4 bits da nibble dir
        D2 = (minuto & 0b11110000) >> 4;// utiliza somente 4 bits da nibble esq
        D3 = minuto & 0b00001111;       // utiliza somente 4 bits da nibble dir

            /*
            sprintf(msg,"___ %d%d:%d%d ...%xseg_ \r\n",
                D0, D1, D2, D3 ,segundo);
            while(BusyUSART());
            putsUSART( msg );
             */

        if (D3 != minAnterior)  // se mudou o minuto, entao mostre novo horario
        {
            StartI2C();
                __delay_us(16); // delay experimental
                WriteI2C(HT16K33_ADDR << 1);

                WriteI2C(0x00);

                WriteI2C(numbertable[D0] & 0xff ); // preenche todos os bits
                WriteI2C(numbertable[D0] >> 8);    // qualquer byte
                // obs: acima como foram usados somente 2 bits, alguma "sujeira"
                // poderia ter ficado escrita no registrador, por isso a necessidade
                // de "preencher" os outros bits com & 0xff

                WriteI2C(numbertable[ D1 ] & 0xFF ); // preenche todos os bits
                WriteI2C(numbertable[ D1 ] >> 8);    // qualquer byte

                WriteI2C(0xFF); // escreve ":" sempre no segundo 0 de mostrar
                WriteI2C(0xFF >> 8);    // qualquer byte

                WriteI2C(numbertable[ D2 ] & 0xFF );// preenche todos os bits
                WriteI2C(numbertable[ D2 ] >> 8);    // qualquer byte

                WriteI2C(numbertable[ D3 ] & 0xFF );// preenche todos os bits
                WriteI2C(numbertable[ D3 ] >> 8);    // qualquer byte

                NotAckI2C();    // encerra envio
                __delay_us(16); // delay experimental
            StopI2C();
            minAnterior=D3; // variavel para proxima checagem e mudanca
        }

        pausa(1);   // utiliza TIMER0 para realizar contagem precisa de 1 seg
        
        
        if ( (contador % 2) == 0) piscaSeg(1);  // gera a piscada ":" par
        else piscaSeg(0); // ou impar " ", a cada mudanca de contador (seg)

        
        sprintf(msg,"\r\nSeg=%d, Cont=%d", segundo, contador );
            while(BusyUSART());
            putsUSART( msg );


            // rotina abaixo de calculo de desvio de segundos
            // ainda deve ser corrigida para o algoritmo correto

            if (contador >= 2 ) // cont >= 40+10
                { 
                    
                    dormir();

                    sprintf(msg,"\r\nSeg=%d, Cont=%d (volta do sleep)", segundo, contador );
                    while(BusyUSART());
                    putsUSART( msg );
                    contador=0;
            
                }

        contador++; // incrementa controle de contagem de segundos
    }
Ejemplo n.º 2
0
void getTemperaturaHumidade (void)
{
    unsigned char TEMPL=0, TEMPH=0, HUMIDL=0, HUMIDH=0;
    unsigned char DUMMY=0, OP=0, BT=0;
    float humidade, temperatura;

    char msg[55];

    LED_AMAR=1;

    //#define StartI2C()  SSPCON2bits.SEN=1;while(SSPCON2bits.SEN)

    StartI2C();             // ACORDAR DEVICE
    __delay_us(16);
    WriteI2C(0xB8);     // endereco Slave do AM2315
    __delay_us(135);
    StopI2C();
    //#define StopI2C()  SSPCON2bits.PEN=1;while(SSPCON2bits.PEN)

    // com clock de 4 mhz:
    // 10K (100) = 1000 ms
    // 1K  (100) = 100 ms
    // 1K  (10)  = 10 ms
    // 1K  (2)   = 2 ms
    // Delay100TCYx();

    __delay_us(25);

    RestartI2C();           // REQUISITAR PEDIDO DE BYTES
    __delay_us(16);
    WriteI2C(0xB8);     // endereco Slave do AM2315
    __delay_us(60);     // manual do AM2315 recomenda minimo de 30us

    WriteI2C(0x03);     // byte que simboliza a temperatura
    __delay_us(60);

    WriteI2C(0x00);     // start byte para leitura
    __delay_us(60);

    WriteI2C(0x04);     // quantidades de bytes a serem lidos;
    //AckI2C();
    __delay_us(16);
    StopI2C();
    //#define StopI2C()  SSPCON2bits.PEN=1;while(SSPCON2bits.PEN)

    __delay_ms(10); // manual do AM2315 recomenda esperar no minimo 10ms

    RestartI2C();
    WriteI2C(0xB9);     // endereco Slave do AM2315
    //AckI2C();         // retirado por nao necessitar (?)
    __delay_us(60);     // manual do AM2315 recomenda minimo de 30us
    IdleI2C();

    OP          = ReadI2C();        // 1o byte
    AckI2C();
    IdleI2C();

    BT          = ReadI2C();        // 2o byte
    AckI2C();
    IdleI2C();

    HUMIDL       = ReadI2C();       // 3o byte
    AckI2C();
    IdleI2C();

    HUMIDH       = ReadI2C();       // 4o byte
    AckI2C();
    IdleI2C();

    TEMPL    = ReadI2C();           // 5o byte
    AckI2C();
    IdleI2C();

    TEMPH    = ReadI2C();           // 6o byte
    AckI2C();
    IdleI2C();

    DUMMY          = ReadI2C();     // 7o byte
    AckI2C();
    IdleI2C();

    DUMMY          = ReadI2C();     // 8 byte
    //__delay_us(16);
    StopI2C();
    //#define StopI2C()  SSPCON2bits.PEN=1;while(SSPCON2bits.PEN)

    LED_VERM=0;
    LED_AMAR=0;
    LED_VERD=1;


    // Calculos obtidos do exemplo do Arduino
    humidade  = HUMIDL;
    humidade *= 256;
    humidade += HUMIDH;
    humidade /= 10;

    temperatura  = TEMPL;
    temperatura *= 256;
    temperatura += TEMPH;
    temperatura /= 10;

    /* ou ainda
    RH = RHH << 8;
    RH |= RHL;

    TEMP = TEMPH << 8;
    TEMP |= TEMPL;
    */

    sprintf (msg, "Temp= %0.2f, Humid= %0.2f .", temperatura, humidade);

    while(BusyUSART());
    putsUSART(msg);

    while(BusyUSART());
    putrsUSART("\n\r");

    LED_VERD=0;

}
Ejemplo n.º 3
0
void imprimir() {
    while(BusyUSART());
    WriteUSART(35);
    while(BusyUSART());
    WriteUSART(88);
    while(BusyUSART());
    itoa(buf, acc_x, 10);
    putsUSART(&buf);
    //putintUSART(&acc_x);
    while(BusyUSART());
    WriteUSART(43);
    while(BusyUSART());
    WriteUSART(89);
    while(BusyUSART());
    //putintUSART(&acc_y);
    itoa(buf, acc_y, 10);
    putsUSART(&buf);
    while(BusyUSART());
    WriteUSART(43);
    while(BusyUSART());
    WriteUSART(90);
    while(BusyUSART());
    //putintUSART(&acc_z);
    itoa(buf, acc_z, 10);
    putsUSART(&buf);
    while(BusyUSART());
    WriteUSART(43);
    while(BusyUSART());
    WriteUSART(33);
    //itoa(buf, temperature, 10);
    //  putsUSART(&buf);
    //  putsUSART(&mid);
    //putsUSART(&start);
    //itoa(buf, acc_x, 10);
    //putintUSART(&acc_x);
    //putsUSART(&mid);
    //itoa(buf, acc_y, 10);
    //putsUSART(&buf);
    //putsUSART(&mid);
    //itoa(buf, acc_z, 10);
    //putsUSART(&buf);
    //putsUSART(&mid);
    //putsUSART(&end);
    //putsUSART(&enter);

}
Ejemplo n.º 4
0
	void WriteUSART(char data)
	{
	 	 while(BusyUSART());
	  	// putcUART(data);
	 	 TXREG = data;      // Write the data byte to the USART
	}
Ejemplo n.º 5
0
void main(void) {

    char mensagem[]="Pronto > ";

    ADCON1=0xF;    // torna todas portas AN0 a AN12 como digitais
                    // na PIC18F2525 somente AN0 a AN4 e AN8 a AN12
                    // nas PICs com 40 pinos, todos ANs de 0 a 12
                    //
                    // PCFG3:PCFG0: A/D Port Configuration Control bits
                    // Note 1:
                    // The POR value of the PCFG bits depends on the value of
                    // the PBADEN Configuration bit. When PBADEN = 1,
                    // PCFG<2:0> = 000; when PBADEN = 0, PCFG<2:0> = 111.


    TRISB=0;    // output do LCD na PORTB / LCD output in PORTB
    initLCD();  // inicia comandos de configuracao do LCD
                // LCD init commands
    /*
     * obs: a biblioteca XLCD.H da PLIB para PIC18, considera como default o LCD
     * conectado na PORTB com as seguintes pinagens:
     *
     Lower Nibble = LCD DATA in PORT B0, B1, B2, B3 (DATA_PORT)
     RW_PIN   in B6   		( PORT for LCD RW , can also be grounded)
     RS_PIN   in B5   		( PORT for LCD RS )
     E_PIN    in B4  		( PORT for LCD Enable Pin )
     */

    TRISA2=1;   // entrada do BOTAO / push-BOTTON input

    TRISC0=0;   // led verde 1
    TRISC1=0;   // led verde 2
    TRISC2=0;   // led verde 3
    TRISC3=0;   // led verde 4
    TRISC4=0;   //buzzer
    TRISC5=0;   //led vermelho

    LED_VERMELHO=1;
    LED1=1;

    Delay10KTCYx(1000);


    while(BusyXLCD());
    WriteCmdXLCD(0x01); // comando para limpar LCD / command to clear LCD

    while(BusyXLCD());
    putrsXLCD ("Serial IO EUSART"); // somente logotipo / just a start logo
    SetDDRamAddr(0x40);     // Linha 2 do Display LCD / second line of LCD

    while(BusyXLCD());
    putrsXLCD ("RS232 PIC18F2525"); // somente logotipo / just a start logo

    SetDDRamAddr(0x00); // volta cursor para linha 0 e posicao 0 do LCD
                        // put cursor in position 0,0 of LCD

    contadorDisplay=0;      // zerando a posicao de caracteres do LCD
                            // reseting the LCD character count

    // Habilitacao dos pinos C6 e C7 para uso da EUSART (explicacao abaixo):
    // Enabling pins C6 and C7 for EUSART (explanation bellow):
    TRISC6=1;
    TRISC7=1;
    RCSTAbits.SPEN=1;
    /*
    The pins of the Enhanced USART are multiplexed
    with PORTC. In order to configure RC6/TX/CK and
    RC7/RX/DT as a USART:
    ? SPEN bit (RCSTA<7>) must be set (= 1)
    ? TRISC<7> bit must be set (= 1)
    ? TRISC<6> bit must be set (= 1)
    Note:
    The EUSART control will automatically
    reconfigure the pin from input to output as
    needed.

     */


    LED1=1;
    LED2=0;
    LED_VERMELHO=0;

    CloseUSART();   // fecha qualquer USART que estaria supostamente aberta antes
                    // just closes any previous USART open port

    
    Delay10KTCYx(1); //Passing 0 (zero) results in a delay of 2,560,000 cycles
    Delay10KTCYx(1000);

    //PORTC=1; Delay10TCYx(50); PORTC=0;

    OpenUSART(  USART_TX_INT_OFF &
                USART_RX_INT_ON &
                USART_ASYNCH_MODE &
                USART_EIGHT_BIT &
                USART_CONT_RX &
                USART_BRGH_LOW,
                51
                );
    // Baud Rate "51" para 2400bps @ 8mhz em modo assincrono
    // de acordo com DS39626E-page 207 do Datasheet em PDF da PIC18F2525

    // These are common comands for 2400 bps running at 8 mhz, assyncronous mode
    // just as being showed in PIC18F2525 Datasheet (DS39626E-page 207)

    //baudUSART (BAUD_8_BIT_RATE | BAUD_AUTO_OFF);

    // page 1158 do pic18_plib.pdf (capitulo 8.17.1.3.3 baud_USART)
    // Set the baud rate configuration bits for enhanced usart operation
    // These functions are only available for processors with
    // enhanced usart capability (EUSART)
    /*
          The Enhanced Universal Synchronous Asynchronous
    Receiver Transmitter (EUSART) module is one of the
    two serial I/O modules. (Generically, the USART is also
    known as a Serial Communications Interface or SCI.)
    The EUSART can be configured as a full-duplex
    asynchronous system that can communicate with
    peripheral devices, such as CRT terminals and
    personal computers. It can also be configured as a half-
    duplex synchronous system that can communicate
    with peripheral devices, such as A/D or D/A integrated
    circuits, serial EEPROMs, etc.
    The Enhanced USART module implements additional
    features, including automatic baud rate detection and
    calibration, automatic wake-up on Sync Break recep-
    tion and 12-bit Break character transmit. These make it
    ideally suited for use in Local Interconnect Network bus
    (LIN bus) systems. (DS39626E-page 201)
     */


    INTCONbits.PEIE = 1;  // interrupcoes para perifericos
    INTCONbits.GIE  = 1;  // interrupcoes globais

    while(BusyUSART());
    putrsUSART("\n\rLed1 e LedVermelho = Interrupcao; Led2 = while wait; Led3/4 = Err");

    while(BusyUSART());
    putrsUSART("\n\rComandos ^E (echo), ^P (lcd), ^L (cls), ^S (status)");

    while(BusyUSART());
    putrsUSART("\n\rTerminal Serial: ");

    while(BusyUSART());
    putsUSART(mensagem);

    LED_VERMELHO=0;
    LED1=1;
    LED2=1;
    
    //LED4=1;

    while (1){

        //LED4=RCIF;
        // o LED4 mostra o status da Interrupcao da RX Serial
        // Led4 shows the status of RX interrupt
      
        //LED3=TXIF;
        // o LED3 mostra o status da suposta interrupcao de TX
        // Led3 shows the suposed TX interrupt state

        LED3=OERR;

        LED4=FERR;
        /*
        bit 2 FERR: Framing Error bit
        1 = Framing error (can be cleared by reading RCREG register and receiving next valid byte)
        0 = No framing error
         *
        bit 1 OERR: Overrun Error bit
        1 = Overrun error (can be cleared by clearing bit, CREN)
        0 = No overrun error
         */


        LED2=~LED2;
        Delay10KTCYx(10);
        // quando esta no modo de espera de tecla* (interrupcao), fica piscando
        // os tres leds para demonstrar a despreocupacao do loop while
        // *na verdade essa espera de tecla eh o RX da serial

        // when being in wait mode (for interrupt *keypress )just flashes the tree
        // leds to demonstrate the un-commitment of while loop to keypress
        // * this keypress event is the serial RX



        // Check for overrun error condition
		if (OERR == 1)
		{
			// Clear the overrun error condition
                        BUZZ=1;
			CREN = 0;
			CREN = 1;
                        Delay100TCYx(10); BUZZ=0;
                }
        LED_VERMELHO = RCIF;    // buffer de recepcao cheio

    }

    return;
}
Ejemplo n.º 6
0
void main()
{
	unsigned char i2cdata = 0, usartdata = 0;
	unsigned char data = 0;
	unsigned char str[] = "nom de la toune";
	unsigned char AUTO[] = "Auto";
	unsigned char NORMAL[] = "Normal";
	unsigned char CUTOM1[] = "Custom 1";
	unsigned char CUTOM2[] = "Custom 2";
	unsigned char CUTOM3[] = "Custom 3";
	// Config position
	short xposMMODE = 40;
	short yposMMODE = 2; //(tranche de 8)


	initialisation();	//Initialise tout


LED1=0;
LED2=1;
LED3=1;
		while(debut)
		{
			//chech dsp pour signal autocorrélation puis debut à 1
			if (read1==0xFF)
				debut=0;
			LED1 = 0;
		}
		LED1 = 1;	
		//Boucle infinie
	while(1)
	{
		//Affichage de l'écran initial
		if(!debut)
		{
			GLCD_Bitmap(logo, 0, 0, 128, 64);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			GLCD_ClearScreen();
			GLCD_Bitmap(PAUSE, 47, 2, 35, 24);
			debut=1;
		}

		if(last_nombre != nombre)	//Si une transition a eu lieu, gérer les menus d'affichage
		{
			switch(nombre)
			{
				case 0:
					
					GLCD_Bitmap(ICONES, 0, 6, 128, 16);
					GLCD_Bitmap(MODEselec, 1, 6, 68, 16);
					GLCD_GoTo(5,7);
					if(modeselect == 0)
						GLCD_WriteString(AUTO,1);
					else if(modeselect == 1)
						GLCD_WriteString(NORMAL,1);	
					else if(modeselect == 2)
						GLCD_WriteString(CUTOM1,1);							
					else if(modeselect == 3)
						GLCD_WriteString(CUTOM2,1);
					else if(modeselect == 4)
						GLCD_WriteString(CUTOM3,1);							
					if(proj)
						GLCD_Bitmap(flecheICO, 75, 5, 8, 8); //SPOT
					else
						GLCD_Bitmap(flecheNULL, 75, 5, 8, 8); //SPOT
					if(strob)
						GLCD_Bitmap(flecheICO, 95, 5, 8, 8); //STROB
					else
						GLCD_Bitmap(flecheNULL, 95, 5, 8, 8); //STROB	
					if(vu)
						GLCD_Bitmap(flecheICO, 115, 5, 8, 8); //BARR
					else
						GLCD_Bitmap(flecheNULL, 115, 5, 8, 8); //BARR
					break;
				case 1:
					//GLCD_ClearScreen();
					GLCD_Bitmap(ICONES, 0, 6, 128, 16);
					GLCD_Bitmap(SPOTselec, 70, 6, 18, 16);
					GLCD_GoTo(5,7);
					if(modeselect == 0)
						GLCD_WriteString(AUTO,0);
					else if(modeselect == 1)
						GLCD_WriteString(NORMAL,0);	
					else if(modeselect == 2)
						GLCD_WriteString(CUTOM1,0);							
					else if(modeselect == 3)
						GLCD_WriteString(CUTOM2,0);
					else if(modeselect == 4)
						GLCD_WriteString(CUTOM3,0);							
					if(proj)
						GLCD_Bitmap(flecheICO, 75, 5, 8, 8); //SPOT
					else
						GLCD_Bitmap(flecheNULL, 75, 5, 8, 8); //SPOT
					if(strob)
						GLCD_Bitmap(flecheICO, 95, 5, 8, 8); //STROB
					else
						GLCD_Bitmap(flecheNULL, 95, 5, 8, 8); //STROB	
					if(vu)
						GLCD_Bitmap(flecheICO, 115, 5, 8, 8); //BARR
					else
						GLCD_Bitmap(flecheNULL, 115, 5, 8, 8); //BARR
					break;
				case 2:
					//GLCD_ClearScreen();
					GLCD_Bitmap(ICONES, 0, 6, 128, 16);
					GLCD_Bitmap(STROBselec, 90, 6, 18, 16);
					GLCD_GoTo(5,7);
					if(modeselect == 0)
						GLCD_WriteString(AUTO,0);
					else if(modeselect == 1)
						GLCD_WriteString(NORMAL,0);	
					else if(modeselect == 2)
						GLCD_WriteString(CUTOM1,0);							
					else if(modeselect == 3)
						GLCD_WriteString(CUTOM2,0);
					else if(modeselect == 4)
						GLCD_WriteString(CUTOM3,0);							
					if(proj)
						GLCD_Bitmap(flecheICO, 75, 5, 8, 8); //SPOT
					else
						GLCD_Bitmap(flecheNULL, 75, 5, 8, 8); //SPOT
					if(strob)
						GLCD_Bitmap(flecheICO, 95, 5, 8, 8); //STROB
					else
						GLCD_Bitmap(flecheNULL, 95, 5, 8, 8); //STROB	
					if(vu)
						GLCD_Bitmap(flecheICO, 115, 5, 8, 8); //BARR
					else
						GLCD_Bitmap(flecheNULL, 115, 5, 8, 8); //BARR
					break;
				case 3:
					//GLCD_ClearScreen();
					GLCD_Bitmap(ICONES, 0, 6, 128, 16);
					GLCD_Bitmap(BARRselec, 110, 6, 18, 16);
					GLCD_GoTo(5,7);
					if(modeselect == 0)
						GLCD_WriteString(AUTO,0);
					else if(modeselect == 1)
						GLCD_WriteString(NORMAL,0);	
					else if(modeselect == 2)
						GLCD_WriteString(CUTOM1,0);							
					else if(modeselect == 3)
						GLCD_WriteString(CUTOM2,0);
					else if(modeselect == 4)
						GLCD_WriteString(CUTOM3,0);								
					if(proj)
						GLCD_Bitmap(flecheICO, 75, 5, 8, 8); //SPOT
					else
						GLCD_Bitmap(flecheNULL, 75, 5, 8, 8); //SPOT
					if(strob)
						GLCD_Bitmap(flecheICO, 95, 5, 8, 8); //STROB
					else
						GLCD_Bitmap(flecheNULL, 95, 5, 8, 8); //STROB	
					if(vu)
						GLCD_Bitmap(flecheICO, 115, 5, 8, 8); //BARR
					else
						GLCD_Bitmap(flecheNULL, 115, 5, 8, 8); //BARR
					break;
				case 4:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,1);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,0);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,0);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,0);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,0);
					break;	
				case 5:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,0);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,1);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,0);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,0);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,0);
					break;
				case 6:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,0);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,0);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,1);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,0);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,0);
					break;
				case 7:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,0);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,0);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,0);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,1);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,0);
					break;
				case 8:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,0);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,0);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,0);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,0);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,1);
					break;					
			}
			last_nombre = nombre;
			}
			//Si on appuit sur le bouton, activer l'actuateur en question ou changer de menu
			if(!ENC_SW)
			{
				while(!ENC_SW);
				Delay10KTCYx(125);
				switch(nombre)
					{
						case 0:
							emplacement=2;
							nombre=modeselect+4;
							last_nombre=0;
						break;
						case 1:
						if(proj)
							proj=0;
						else
							proj=1;
						last_nombre=0;
						break;
						case 2:
						if(strob)
							strob=0;
						else
							strob=1;
						last_nombre=0;
						break;
						case 3:
						if(vu)
							vu=0;
						else
							vu=1;
						last_nombre=0;
						break;
						case 4:
							modeselect=0;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
						case 5:
							modeselect=1;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
						case 6:
							modeselect=2;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
						case 7:
							modeselect=3;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
						case 8:
							modeselect=4;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
					}	
			}
		
		//Si la pédale est appuyée, changer de on-off
		if(!PORTBbits.RB3)
		{
			while(!PORTBbits.RB3);		//Attente que la pédale soit relâché
			if(etatplay==0)
			{
				play=1;
				pause=0;
				etatplay=1;
			}
			else
			{
				pause=1;
				last_nombre=9;
				etatplay=0;
			}
		}
// ---------------------------------------------------------------------------------------
// PLAY
		if(play)
		{
			//Affiche play à l'écran
			GLCD_Bitmap(PLAY, 47, 2, 35, 24);
			
			//Envoie le mode vers le dsp
			euart_out=modeselect;
			while(BusyUSART());
			putcUSART(euart_out);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			GLCD_ClearScreen();
			last_nombre=9;	
			play=1;
		}
// ---------------------------------------------------------------------------------------
// PAUSE
		if(emplacement == 1)
		{
			//Si non-pause, afficher les barres graphiques
			if(pause==0)
			{
				graphVU(chan_L,chan_R);
			}
			//Si pause, afficher l'image du pause
			else if(pause==1 && last_nombre!=nombre)
			{
				GLCD_ClearScreen();			
				GLCD_Bitmap(PAUSE, 47, 2, 35, 24);
				last_nombre=9;
			}
			//Affiche le nom de la chanson en cours
			GLCD_GoTo(2,0);
			if(toune==1)
				GLCD_WriteString(music_1,0);						
			else if(toune==2)
				GLCD_WriteString(music_2,0);
			else if(toune==3)
				GLCD_WriteString(music_3,0);			
		}

// I2C,  actualiser la FFT et envoyer les données vers le contrôleur principal
		if(flag_i2c)
		{
			flag_i2c=0;
			//Si trame FFT initiale détecté, commence à mettre à jour la FFT
			if((read3&0b00010000)==0x10)
			{
				compteur_fft=1; 
			}
			//Met à jour chaque trame de la FFT
			switch(compteur_fft)
					{
						case 1:
							fft1=(read3&0b00001111);
						break;
						case 2:
							fft2=(read3&0b00001111);
						break;
						case 3:
							fft3=(read3&0b00001111);
						break;
						case 4:
							fft4=(read3&0b00001111);
						break;
						case 5:
							fft5=(read3&0b00001111);
						break;
						case 6:
							fft6=(read3&0b00001111);
						break;
						case 7:
							fft7=(read3&0b00001111);
						break;
						case 8:
							fft8=(read3&0b00001111);
						break;
						case 9:
							fft9=(read3&0b00001111);
						break;
						case 10:
							fft10=(read3&0b00001111);
						break;
						case 11:
							fft11=(read3&0b00001111);
						break;
						case 12:
							fft12=(read3&0b00001111);
						break;
						case 13:
							fft13=(read3&0b00001111);
						break;
						case 14:
							fft14=(read3&0b00001111);
						break;
						case 15:
							fft15=(read3&0b00001111);
						break;
						case 16:
							fft16=(read3&0b00001111);
							compteur_fft=0;
						break;
						default:
							LED2=1;
						break;
					}	
			//Lorsque la FFT est actualiser, la faire afficher à l'écran
			if(compteur_fft==1 && (emplacement ==1)  && (etatplay==1))
				graphFFT(2*fft1,2*fft2,2*fft3,2*fft4,2*fft5,2*fft6,2*fft7,2*fft8,2*fft9,2*fft10,2*fft11,2*fft12,2*fft13,2*fft14,2*fft15,2*fft16);	
			compteur_fft++;
			//Choix de la chanson selon les données reçu
			if((read4&0b00001111)==0b00000001)
				toune=1;
			else if((read4&0b00001111)==0b00000010)
				toune=2;
			else if((read4&0b00001111)==0b00000011)
				toune=3;
			//Masques pour savoir les actuateurs à activer
			i2c_actuateur=0b00001000;
			if(vu && !pause)
				i2c_actuateur |= 0b00000001;			
			if(proj && !pause)
				i2c_actuateur |= 0b00000010;
			if(strob && !pause)
				i2c_actuateur |= 0b00000100;
			
			//Émet I2C uniquement sur nouvelles données
			if((last_i2c_1 != read2) || (last_i2c_2 != i2c_actuateur))
			{
				tst_str[1] = read2;
				tst_str[2] = i2c_actuateur;
				send_str_I2C(0x40, tst_str);
			}
			last_i2c_1 = read2;		
			last_i2c_2 = i2c_actuateur;	
		}
		if(play)
		{
			while(BusyUSART());
			putcUSART(euart_out);
			play=0;
		}
	}
} 
Ejemplo n.º 7
0
void interrupt Interrupcao(void){

    char buffer[4];
    /* a string buffer ira guardar um numero decimal (0 a 32) traduzido pela
     * funcao itoa, onde ira transformar o numero inteiro em string com apontador
     * o tamanho poderia ser 3, mas o inteiro vai ate 3 posicoes + null
     *
     * the buffer string variable will hold a decimal number (0 to 32) that was
     * converted by the itoa function, changing a integer number into a string
     * pointer
     * its size could be only 3, but the interger goes up to 3 positions + null end
     */


    // LED_VERMELHO = ~LED_VERMELHO;
    // muda o status do LED_VERMELHO quando a MCU entrar em interrupcao
    // changes the LED_VERMELHO when the MCU interrupts

    // BUZZ=1; Delay100TCYx(10); BUZZ=0;
    // toca o buzzer para cada interrupcao
    // plays the buzzer for each interrupt

    if (RCIF)   // se existe interrupcao aguardando...
                // teoricamente este RCIF nao precisaria de verificacao
                // pois se a rotina de Interrupcao ja foi chamada, entao
                // nem seria necessario verifica-la
                // mas os LED1 e LED_VERMELHO servem justamente para comprovar
                // que o RCIF sempre ira existir, quando mudam juntos (leds)

                // Theoretically this RCIF "if" check should never be necessary
                // but just to confirm the RCIF, the two leds (LED1 and
                // LED_VERMELHO) will always change together.
        {

        RCIE = 0;   // desabilita interrupts de RX para tratar a entrada
                    // disables RX interrupts to treat input

        LED1 = ~LED1;
        // muda o status do primeiro LED
        // inverts the LED1 status

        chRX = ReadUSART();
        // le caractere da Serial / read a character from Serial

        if ( chRX>31 && chRX<127 && !BOTAO)
            // filtra apenas os caracteres texto comuns
            // just filter the common readable text characters
        {

            // Se o Echo Serial esta ativo, entao imprima o caractere na Serial
            // If Serial Echo is on, then send the character to Serial Port
            if (SerialEcho)
                {
                    while (BusyUSART()); // espera nao ocupado / waits non busy
                    WriteUSART(chRX);    // envia caractere na Porta Serial
                                         // sends the character in Serial Port
                }

            // Se o LcdDisplay esta ativo, entao imprima o caractere
            // If Lcd Display is enabled, print the character in LCD
            if (LcdDisplay)
            {
                while (BusyXLCD());
                WriteDataXLCD(chRX);

                contadorDisplay++;      // contador de caracteres para tabular
                                        // LCD character tabulation count
                if (contadorDisplay==16)    // se chegar ao final da primeira linha
                                            // if reaches the end of first line
                {
                    SetDDRamAddr(0x40); // comando para pular para segunda linha
                                        // command for going to second line
                    if (SerialEcho)
                    {
                        while (BusyUSART());
                        putrsUSART("\r\n"); // imprime RETURN e NEWLINE (inicio)
                                            // prints Carriage RETURN and Newline
                    }

                }

                if (contadorDisplay==32)    // se chegar ao final da segunda linha
                                            // if reaches the end of second line
                {
                    SetDDRamAddr(0x00);     // pula novamente para primeira linha
                                            // go again to first line
                    contadorDisplay=0;  // ja na primeira linha, limpa contador
                                        // in first line, clear the char counter
                    if (SerialEcho)
                    {
                        while (BusyUSART());
                        putrsUSART("\r\n"); // imprime RETURN e NEWLINE (inicio)
                                            // prints Carriage RETURN and Newline
                    }
                }

            }



        }
        else            // filtra todos demais Controls e Caracteres Especiais
                        // this is the state of non-text characters being filtered

        if (BOTAO)  // se o BOTAO de debug estiver pressionado, nao filtra controle
                    //if pushBOTTON is pressed, do not filter control characters
        {
                    while (BusyUSART());
                    WriteUSART(chRX);
        }
        else
        switch (chRX)
        {
            case 0x05 :      // Caractere ^E
                SerialEcho=!SerialEcho;
                while(BusyUSART());
                putrsUSART("\r\n[ECHO ");
                if (SerialEcho) putrsUSART("ON]"); else putrsUSART("OFF]");
                break;
                /*
                 * Control-E:
                 * Rotina para ligar e desligar o ECHO na porta serial
                 * Routine to turn on and off the ECHO in serial port
                 */

            case 0x10 :      // Caractere ^P
                LcdDisplay=!LcdDisplay;
                while(BusyUSART());
                putrsUSART("\r\n[LCD ");
                if (LcdDisplay) putrsUSART("ON]"); else putrsUSART("OFF]");
                break;
                /*
                 * Contro-P:
                 * Rotina para ligar e desligar a amostragem de Caractere no LCD
                 * Routine to turn on and off the display of characters in LCD
                 */

            case 0x0C :     // Caractere ^L (FormFeed)
                putrsUSART("\r\n[LCD CLS]");
                while(BusyXLCD());
                WriteCmdXLCD(0x01); // Comando para limpar o LCD
                contadorDisplay=0;
                break;
                /*
                 * Control-L: (LimpaTela / FormFeed)
                 * Rotina para Limpar a Tela
                 * Routine to CLear Screen (CLS)
                 */

            case 0x13 :     // Caractere ^S
                putrsUSART("\r\n[Status Lcd:");
                if (LcdDisplay) putrsUSART("On"); else putrsUSART("Off");
                putrsUSART(" Echo:");
                if (SerialEcho) putrsUSART("On"); else putrsUSART("Off");
                putrsUSART(" charLCD:");
                
                itoa ( buffer, contadorDisplay, 10);
                // itoa necessita da biblioteca <stdlib.h>
                // itoa needs the include stdlib.h
                putrsUSART( buffer );
                putrsUSART("]\r\n");
                /*
                 * Control-S:
                 * Mostra o Status do Echo, do LCD, e da quantidade de caracteres
                 * no LCD
                 * Shows the Status of Echo, LCD and characteres number in LCD
                 */
                
                break;

            default:
               
                ;
        }

        




        // two Peripheral Interrupt Request (Flag) registers (PIR1 and PIR2)
        // RCIF: EUSART Receive Interrupt Flag bit

        //PIR1bits.RCIF = 0; // PIR1 no registro RCIF
        RCIE = 1; // Re-Habilita a Interrupcao de Recepcao
                  // Re-Enable RX Interrupts

        RCIF = 0; // PIR1 no registro RCIF
        // limpa o registrador de interrupcao, e sai da interrupcao
        // clear the interrupt register, and quits it

        }
}
Ejemplo n.º 8
0
/******************************************************************************************
*    COMMAND FUNCTIONS        *
******************************************************************************************/
void ProcessCommand(void)
{
    if (HEART_B == '1')
        ACT_LED_01 = 0; //Turn it ON (inverted open drain)
    if (COMMAND_DATA[0] == 'R')// READ COMMAND --------------------------------------------
    {


        if (COMMAND_DATA[1] == '*')// READ ALL REGISTERS
        {

            Read_Analog_Inputs(); // READ ANALOG PERIPHERIALS****
            Read_Digital_Inputs(); // READ DIGITAL INPUT PERIPHERIALS**
            Read_Digital_Outputs(); // READ DIGITAL OUTPUT PERIPHERIALS**

            SEND_TX_START();    // START TRANSMISSION
            SEND_ANALOG_DATA();
            WriteUSART(0x2C);
            while (BusyUSART()); // Send a  ,
            SEND_DIGITAL_INPUT_DATA();
            WriteUSART(0x2C);
            while (BusyUSART()); // Send a  ,
            SEND_DIGITAL_OUTPUT_DATA();
            SEND_TX_STOP(); // End all transmissions

        }

        if (COMMAND_DATA[1] == 'C')// READ REGISTER LIST
        {
            if (COMMAND_DATA[2] == '0')// READ INFO REGISTER 0  MODEL
            {
                for (unsigned char n=0; n <= 7; n++ ) //Reset Buffer
                    TRANSMITT_DATA[n] = EEPROM_READ(n); // COPY BUFFER TO COMMAND DATA for further processing
                SEND_TX_RESPONSE();
            }
            else if (COMMAND_DATA[2] == '1')// READ INFO REGISTER 1  FIRMWARE
            {
                unsigned char d=0x08;
                for (unsigned char n=0; n <= 7; n++ ) //Reset Buffer
                    TRANSMITT_DATA[n] = EEPROM_READ(d),d++; // COPY BUFFER TO COMMAND DATA for further processing
                    
                SEND_TX_RESPONSE();
            }
            else if (COMMAND_DATA[2] == '2')// READ INFO REGISTER 2  ADDRESS
            {
                TRANSMITT_DATA[0] = EEPROM_READ(0x10); // AdDDRES 1
                TRANSMITT_DATA[1] = EEPROM_READ(0x11); // AdDDRES 1
                SEND_TX_RESPONSE();
            }
            else if (COMMAND_DATA[2] == '3')// READ INFO REGISTER 3  DEVICE SERIAL NUMBER
            {
                TRANSMITT_DATA[0] = SERIAL[0];
                TRANSMITT_DATA[1] = SERIAL[1];
                TRANSMITT_DATA[2] = SERIAL[2];
                TRANSMITT_DATA[3] = SERIAL[3];
                TRANSMITT_DATA[4] = SERIAL[4];
                TRANSMITT_DATA[5] = SERIAL[5];
                TRANSMITT_DATA[6] = SERIAL[6];
                TRANSMITT_DATA[7] = SERIAL[7];
                SEND_TX_RESPONSE(); // Send list character

            }
            else if (COMMAND_DATA[2] == '4')// READ INFO REGISTER 4  LIST DEVICE
            {
                TRANSMITT_DATA[0] = '@', SEND_TX_RESPONSE(); // Send list character
            }
        }


        else if (COMMAND_DATA[1] == 'A')// READ ANALOG INPUTS ADC
        {
            Read_Analog_Inputs(); // READ ANALOG PERIPHERIALS****
              

            if (COMMAND_DATA[2] == '*') // READ ALL ANALOG DATA AND SEND IT
                SEND_TX_START() , SEND_ANALOG_DATA(), SEND_TX_STOP();
            else if (COMMAND_DATA[2] == '0')// READ ANALOG REGISTER 1
                itoa( TRANSMITT_DATA, ADCValue[0],10), SEND_TX_RESPONSE(); //convert to string VAL 1 TO 1024

            else if (COMMAND_DATA[2] == '1')// READ ANALOG REGISTER 2
                itoa( TRANSMITT_DATA, ADCValue[1],10), SEND_TX_RESPONSE(); //convert to string VAL 1 TO 1024

            else if (COMMAND_DATA[2] == '2')// READ ANALOG REGISTER 3
                itoa( TRANSMITT_DATA, ADCValue[2],10), SEND_TX_RESPONSE(); //convert to string VAL 1 TO 1024

            else if (COMMAND_DATA[2] == '3')// READ ANALOG REGISTER 4
                itoa( TRANSMITT_DATA, ADCValue[3],10), SEND_TX_RESPONSE(); //convert to string VAL 1 TO 1024

            else if (COMMAND_DATA[2] == '4')// READ ANALOG REGISTER 5
                itoa( TRANSMITT_DATA, ADCValue[4],10), SEND_TX_RESPONSE(); //convert to string VAL 1 TO 1024


        }

        else if (COMMAND_DATA[1] == 'I')// READ DIGITAL INPUTS
        {
            Read_Digital_Inputs(); // READ DIGITAL PERIPHERIALS**

            if (COMMAND_DATA[2] == '*') // READ ALL DIGITAL INPUTS AND SEND IT
                SEND_TX_START() , SEND_DIGITAL_INPUT_DATA(), SEND_TX_STOP();
            else if (COMMAND_DATA[2] == '0')// READ DIGITAL INPUT REGISTER 1
                TRANSMITT_DATA[0] = INPUTValue[0], SEND_TX_RESPONSE();
            else if (COMMAND_DATA[2] == '1')// READ DIGITAL INPUT REGISTER 2
                TRANSMITT_DATA[0] = INPUTValue[1], SEND_TX_RESPONSE();
            else if (COMMAND_DATA[2] == '2')// READ DIGITAL INPUT REGISTER 3
                TRANSMITT_DATA[0] = INPUTValue[2], SEND_TX_RESPONSE();

        }

        else if (COMMAND_DATA[1] == 'O')// READ DIGITAL OUTPUTS
        {
            
            Read_Digital_Outputs(); // READ DIGITAL PERIPHERIALS**

            if (COMMAND_DATA[2] == '*') // READ ALL DIGITAL INPUTS AND SEND IT            
                SEND_TX_START() , SEND_DIGITAL_OUTPUT_DATA(), SEND_TX_STOP();

            else if (COMMAND_DATA[2] == '0')// READ DIGITAL OUTPUTS REGISTER 1
            {
                if (OUT_00)
                    TRANSMITT_DATA[0] = '1';
                else
                    TRANSMITT_DATA[0] = '0';
                SEND_TX_RESPONSE();
            }
            else if (COMMAND_DATA[2] == '1')// READ DIGITAL OUTPUTS REGISTER 2
            {
                if (OUT_01)
                    TRANSMITT_DATA[0] = '1';
                else
                    TRANSMITT_DATA[0] = '0';
                SEND_TX_RESPONSE();
            }


        }

    }




    else if (COMMAND_DATA[0] == 'W')// WRITE COMMAND ----------------------------------------
    {
        if (COMMAND_DATA[1] == 'O')// WRITE DIGITAL OUTPUT
        {
            if (COMMAND_DATA[2] == '0')// WRITE OUTPUT REGISTER 1
            {
                if (COMMAND_DATA[3] == '1')
                    OUT_00 = 1;
                else
                    OUT_00 = 0;
                TRANSMITT_DATA[0] = '1', SEND_TX_RESPONSE();
            }   
           else if (COMMAND_DATA[2] == '1')// WRITE OUTPUT REGISTER 2
           {
                if (COMMAND_DATA[3] == '1')
                    OUT_01 = 1;
                else
                    OUT_01 = 0;
                TRANSMITT_DATA[0] = '1', SEND_TX_RESPONSE();
           }    

        }
        if (COMMAND_DATA[1] == 'C')// WRITE CONFIGURATION
        {
            if (COMMAND_DATA[2] == '2')// WRITE CONFIGURATION REGISTER 2
            {

                EEPROM_WRITE(0x10, COMMAND_DATA[3]);
                Delay10TCYx(30);
                EEPROM_WRITE(0x11, COMMAND_DATA[4]);
                Delay10TCYx(30);
                Add_HI = COMMAND_DATA[3];
                Add_LO = COMMAND_DATA[4];
                TRANSMITT_DATA[0] = '1', SEND_TX_RESPONSE();

            }
        }
        

    }
    
    ACT_LED_01 = 1; //Turn it OFF (inverted open drain)
    return;
}
Ejemplo n.º 9
0
void SEND_TX_START(void)
{
    WriteUSART(StartTransmission);
    while (BusyUSART());
}
Ejemplo n.º 10
0
void SEND_TX_DATA(void)
{
    putsUSART(TRANSMITT_DATA);
    while (BusyUSART());
    Clear_TX_Buffer();
}
Ejemplo n.º 11
0
void uart_recv_int_handler() {
#ifdef __USE18F26J50
    if (DataRdy1USART()) {
        uc_ptr->buffer[uc_ptr->buflen] = Read1USART();
#else
#ifdef __USE18F46J50
    if (DataRdy1USART()) {
        uc_ptr->buffer[uc_ptr->buflen] = Read1USART();
#else
    if (DataRdyUSART()) {
        buffer_temp[buf_len] = ReadUSART();
#endif
#endif
        uc_ptr->buflen++;
        buf_len++;
        parseUART();

        // check if a message should be sent
    }
#ifdef __USE18F26J50
    if (USART1_Status.OVERRUN_ERROR == 1) {
#else
#ifdef __USE18F46J50
    if (USART1_Status.OVERRUN_ERROR == 1) {
#else
    if (USART_Status.OVERRUN_ERROR == 1) {
#endif
#endif
        // we've overrun the USART and must reset
        // send an error message for this
        RCSTAbits.CREN = 0;
        RCSTAbits.CREN = 1;
        ToMainHigh_sendmsg(0, MSGT_OVERRUN, (void *) 0);

    }
}

void init_uart_recv(uart_comm *uc) {
    uc_ptr = uc;
    uc_ptr->buflen = 0;
    buf_len = 0;
    command_length = 0;
    command_count = 0;
    State = GET_MSGID;
}

void parseUART()
{
    unsigned char x = uc_ptr->buflen;
   // uart_write(1, &x);
    switch(State)
    {
        case(GET_MSGID):
        {
            command_length = buffer_temp[buf_len -1] & 0xF;
            command_length = command_length;
            if(command_length != 0)
            {
                State = GET_COMMAND;
            }
            else
            {
                State = CHECKSUM;
            }
            break;
        }
        case(GET_COMMAND):
        {
            if(command_count+1 < command_length)
            {
                command_count++;
            }
            else
            {
                State = CHECKSUM;
            }
            break;
        }
        case(CHECKSUM):
        {
            ToMainLow_sendmsg(buf_len ,MSGT_PARSE, &buffer_temp[0]);
            uc_ptr->buflen = 0;
            buf_len = 0;
            State = GET_MSGID;
            command_count = 0;
            command_length = 0;
            break;
        }
    }
}


void uart_write(unsigned char length, unsigned char *msg){

    unsigned char i = 0;
    for(i = 0; i < length; i++){

    #ifdef __USE18F26J50
        while(Busy1USART());
        Write1USART(msg[i]);
    #else
    #ifdef __USE18F46J50
        while(Busy1USART());
        Write1USART(msg[i]);
    #else
        while(BusyUSART());
        WriteUSART(msg[i]);
    #endif
    #endif
    }
}