Autor Tema: PIC32 ETHERNET STARTER KIT  (Leído 16515 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Suky

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 6758
Re: PIC32 ETHERNET STARTER KIT
« Respuesta #30 en: 30 de Marzo de 2012, 12:25:32 »
Puede ser que la versión de C32 tenga alguna modificación. Busca el *.h que define el tema de los vectores para controlar eso. Respecto a habilitar los demás módulos UART, busca en el foro, Nocturno trato el tema.


Saludos!
No contesto mensajes privados, las consultas en el foro

Desconectado IngRandall

  • PIC18
  • ****
  • Mensajes: 383
Re: PIC32 ETHERNET STARTER KIT
« Respuesta #31 en: 02 de Abril de 2012, 10:34:29 »
Bueno les comento que ya me funciono, es algo muy raro, pero funciona, en una web de electrónica que no me acuerdo cual es, vi que la persona enumeraba los uart del pic pero invertía el uart 2A y 3A, hoy lo primero que hizo fue invertirlos en mi codigo, y ver si de casualidad me funcionaba, y funciono  :D :D :D

Yo en mi código le cambie el nombre del uart3 al uart2 y probé y me funciono... la verdad no tengo ni idea, aquí voy a dejar mi código funcionando y algunas imágenes.


Código: [Seleccionar]
/*********************************************************************
 *
 *                  UART Interrupt Example
 *
 *********************************************************************
 * FileName:        uart_interrupt.c
 * Dependencies:
 * Processor:       PIC32
 *
 * Complier:        MPLAB C32
 *                  MPLAB IDE
 * Company:         Microchip Technology Inc.
 *
 * Software License Agreement
 *
 * The software supplied herewith by Microchip Technology Incorporated
 * (the “Company”) for its PIC32 Microcontroller is intended
 * and supplied to you, the Company’s customer, for use solely and
 * exclusively on Microchip PIC32 Microcontroller products.
 * The software is owned by the Company and/or its supplier, and is
 * protected under applicable copyright laws. All rights are reserved.
 * Any use in violation of the foregoing restrictions may subject the
 * user to criminal sanctions under applicable laws, as well as to
 * civil liability for the breach of the terms and conditions of this
 * license.
 *
 * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 *
 *
 * $Id: uart_interrupt.c 9390 2008-06-16 23:43:04Z rajbhartin $
 * $Name: x.x $
 *
 **********************************************************************/

/***********************************************************************************
UART Interrupt Example README
 ***********************************************************************************
 * Objective: Become familiar with PIC32MX tool suite and understand
 *   basic UART Interrupt operations.
 *
 * Tools:
 * 1. MPLAB with PIC32MX support
 * 2. C32 Compiler
 * 3. Explorer 16 Rev 4 or 5 board.
 * 4. RS-232 Cable
 * 5. A Terminal program for Windows - HyperTerminal
 *
 *
 ***********************************************************************************
 ***********************************************************************************/

#include <plib.h> // Peripheral Library

#pragma config FNOSC = FRCPLL//Oscilador Interno con PPL
#pragma config POSCMOD = OFF //Oscilador externo apagado
#pragma config FPBDIV = DIV_1//divisor Bus Periféricos
#pragma config FWDTEN = OFF//Wachdog deshabilitado
#pragma config FPLLODIV = DIV_1//Pos-Divisor PPL 1/1
#pragma config FPLLIDIV = DIV_2//Pre-Divisor PPL 1/2
#pragma config FPLLMUL = MUL_20// 20xPPL

#define GetSystemClock() (80000000ul) // Hz
#define GetInstructionClock() (GetSystemClock()/1) // Normally GetSystemClock()/4 for PIC18, GetSystemClock()/2 for PIC24/dsPIC, and GetSystemClock()/1 for PIC32.  Might need changing if using Doze modes.
#define GetPeripheralClock() (GetSystemClock()/1) // Normally GetSystemClock()/4 for PIC18, GetSystemClock()/2 for PIC24/dsPIC, and GetSystemClock()/1 for PIC32.  Divisor may be different if using a PIC32 since it's configurable.

#define DESIRED_BAUDRATE    (9600)      //The desired BaudRate

#define LED_ON_OFF_TRIS (TRISAbits.TRISA0)
#define LED_ON_OFF (LATAbits.LATA0)

#define LED_Rx_U1_TRIS (TRISAbits.TRISA1)
#define LED_Rx_U1 (LATAbits.LATA1)
#define LED_Rx_U2_TRIS (TRISAbits.TRISA4)
#define LED_Rx_U2 (LATAbits.LATA4)
#define LED_Tx_U2_TRIS (TRISAbits.TRISA3)
#define LED_Tx_U2 (LATAbits.LATA3)
#define LED_Tx_U1_TRIS (TRISAbits.TRISA2)
#define LED_Tx_U1 (LATAbits.LATA2)

void WriteString_U1(const char *string);
void WriteString_U2(const char *string);

int main(void)
{
DelayMs(200);

DDPCONbits.JTAGEN=0;

configuracion_puertos();
configuracion_uart1();
configuracion_uart2();

// Configure the device for maximum performance but do not change the PBDIV
// Given the options, this function will change the flash wait states, RAM
// wait state and enable prefetch cache but will not change the PBDIV.
// The PBDIV value is already set via the pragma FPBDIV option above..
SYSTEMConfig(GetSystemClock(), SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

    // configure for multi-vectored mode
    INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);

    // enable interrupts
    INTEnableInterrupts();

   WriteString_U1("*** UART 1 Status: OK ***\r\n");
   WriteString_U2("*** UART 2 Status: OK  ***\r\n");

while (1){
LED_ON_OFF = 1;
}
}

void WriteString_U1(const char *string)
{
    while(*string != '\0')
    {
        while(!UARTTransmitterIsReady(UART1));

        UARTSendDataByte(UART1, *string);

        string++;

        while(!UARTTransmissionHasCompleted(UART1));
    }
}

void WriteString_U2(const char *string)
{
    while(*string != '\0')
    {
        while(!UARTTransmitterIsReady(UART2));

        UARTSendDataByte(UART2, *string);

        string++;

        while(!UARTTransmissionHasCompleted(UART2));
    }
}

void PutCharacter_U1(const char character)
{
LED_Tx_U1 = 1;

    while(!UARTTransmitterIsReady(UART1));


    UARTSendDataByte(UART1, character);


    while(!UARTTransmissionHasCompleted(UART1));

LED_Tx_U1 = 0;
}

void PutCharacter_U2(const char character)
{
LED_Tx_U2 = 1;

    while(!UARTTransmitterIsReady(UART2));


    UARTSendDataByte(UART2, character);


    while(!UARTTransmissionHasCompleted(UART2));

LED_Tx_U2 = 0;
}

void configuracion_puertos()
{
LED_ON_OFF_TRIS =   0;
LED_Rx_U2_TRIS = 0;
LED_Tx_U2_TRIS = 0;
LED_Rx_U1_TRIS = 0;
LED_Tx_U1_TRIS = 0;

LED_Tx_U1 = 0;
LED_Rx_U1 = 0;
LED_Tx_U2 = 0;
LED_Rx_U2 = 0;
}

void configuracion_uart1()
{
    UARTConfigure(UART1, UART_ENABLE_PINS_TX_RX_ONLY);
    UARTSetFifoMode(UART1, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY);
    UARTSetLineControl(UART1, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1);
    UARTSetDataRate(UART1, GetPeripheralClock(), DESIRED_BAUDRATE);
    UARTEnable(UART1, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX));

// Configure UART1 RX Interrupt
INTEnable(INT_SOURCE_UART_RX(UART1), INT_ENABLED);
    INTSetVectorPriority(INT_VECTOR_UART(UART1), INT_PRIORITY_LEVEL_2);
    INTSetVectorSubPriority(INT_VECTOR_UART(UART1), INT_SUB_PRIORITY_LEVEL_0);
}

void configuracion_uart2()
{
    UARTConfigure(UART2, UART_ENABLE_PINS_TX_RX_ONLY);
    UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY);
    UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1);
    UARTSetDataRate(UART2, GetPeripheralClock(), DESIRED_BAUDRATE);
    UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX));

// Configure UART2 RX Interrupt
INTEnable(INT_SOURCE_UART_RX(UART2), INT_ENABLED);
    INTSetVectorPriority(INT_VECTOR_UART(UART2), INT_PRIORITY_LEVEL_2);
    INTSetVectorSubPriority(INT_VECTOR_UART(UART2), INT_SUB_PRIORITY_LEVEL_0);
}

void Delay10us(DWORD dwCount)
{
volatile DWORD _dcnt;

_dcnt = dwCount*((DWORD)(0.00001/(1.0/GetInstructionClock())/10));
while(_dcnt--)
{
Nop();
Nop();
Nop();
}
}

void DelayMs(WORD ms)
{
    unsigned char i;
    while(ms--)
    {
        i=4;
        while(i--)
        {
            Delay10us(25);
        }
    }
}

// UART 1 interrupt handler
// it is set at priority level 2
void __ISR(_UART1_VECTOR, ipl2) IntUart1Handler(void)
{
LED_Rx_U1 = 1;

// Is this an RX interrupt?
if(INTGetFlag(INT_SOURCE_UART_RX(UART1)))
{
// Clear the RX interrupt Flag
    INTClearFlag(INT_SOURCE_UART_RX(UART1));

// Echo what we just received.
PutCharacter_U1(UARTGetDataByte(UART1));

}

// We don't care about TX interrupt
if ( INTGetFlag(INT_SOURCE_UART_TX(UART1)) )
{
INTClearFlag(INT_SOURCE_UART_TX(UART1));
}

LED_Rx_U1 = 0;
}

// UART 2 interrupt handler
// it is set at priority level 2
void __ISR(_UART2_VECTOR, ipl2) IntUart2Handler(void)
{
LED_Rx_U2 = 1;

// Is this an RX interrupt?
if(INTGetFlag(INT_SOURCE_UART_RX(UART2)))
{
// Clear the RX interrupt Flag
    INTClearFlag(INT_SOURCE_UART_RX(UART2));

// Echo what we just received.
PutCharacter_U2(UARTGetDataByte(UART2));
}

// We don't care about TX interrupt
if ( INTGetFlag(INT_SOURCE_UART_TX(UART2)) )
{
INTClearFlag(INT_SOURCE_UART_TX(UART2));
}

LED_Rx_U2 = 1;
}


//while(1){LED_Tx_U1 = 1;DelayMs(100);LED_Tx_U1 = 0;DelayMs(100);}


Desconectado IngRandall

  • PIC18
  • ****
  • Mensajes: 383
Re: PIC32 ETHERNET STARTER KIT
« Respuesta #32 en: 02 de Abril de 2012, 12:27:16 »
Mi proxima prueba fue quitarle el cristal al Ethernet Starter kit y cambiarle los fusibles para que funcionara el stack TCPIP de Microchip con el reloj interno y... Funciono!!!!!!!!!!

Comprobado, el stack TCPIP de Microchip con el reloj interno funciona.

Lo malo es que en mi board no funciona, creo q algo se daño, voy a revisar y les comento.

Desconectado MGLSOFT

  • Moderadores
  • DsPIC33
  • *****
  • Mensajes: 7918
Re: PIC32 ETHERNET STARTER KIT
« Respuesta #33 en: 02 de Abril de 2012, 13:16:06 »
Un pequeño paso para el hombre, pero uno grande para el foro !!!   ((:-)) ((:-)) ((:-)) ((:-)) ((:-))
Todos los dias aprendo algo nuevo, el ultimo día de mi vida aprenderé a morir....
Mi Abuelo.

Desconectado IngRandall

  • PIC18
  • ****
  • Mensajes: 383
Re: PIC32 ETHERNET STARTER KIT
« Respuesta #34 en: 02 de Abril de 2012, 13:17:56 »
Si, bastante grande, gracias al foro.

Desconectado IngRandall

  • PIC18
  • ****
  • Mensajes: 383
Re: PIC32 ETHERNET STARTER KIT
« Respuesta #35 en: 05 de Mayo de 2012, 13:47:14 »
hola, estoy intentando juntar los archivos del stack ethernet en una sola carpeta,  logro hacer que me compile, pero no se conecta, y la verdad no tengo ni idea de por que no me conecta, su puestamente estan los archivos necesarios, cambie la ubicacion en los archivos pero no conecta  :5] :5] :5]


 

anything