TODOPIC
Microcontroladores PIC => Pic32 => Mensaje iniciado por: Trust en 19 de Abril de 2010, 10:37:41
-
Hola,estoy probando la placa PIC32 Ethernet Starter Kit y el problema que tengo es que no puedo hacerla funcionar porque no me la reconoce el Windows 7. La tarjeta enciende los leds cuando le enchufo el usb pero he intentado reinstalar varias veces el Mplab ide 8.46 y no consigo hacerlo funcionar.
En el administrador de dispositivos de W7, me sale que no estan instalados los controladores para este dispositivo.
He buscado informacion pero, no encuentro nada que me diga como solucionar el problema. Me sale un mensaje con un error 1609 y 1332.
Saludos.
-
Hola, esas tarjetas traen manuales de usuario muy completos, ¿has tenido oportunidad de leerlos?
-
Hola, yo tengo la tarjeta y en XP va bien. No tengo manera de probarte que hacer en seven.
-
Me he leido el manual que explica la instalacion del driver y ya me funciona. :P
La verdad es que antes de preguntar hay que leer y releer bien, las prisas son malas consejeras.
Tengo que estudiar mucho como funciona este Kit que es muy diferente a lo que yo conocia.
Seria muy interesante que hicieramos un tema con ejemplos de programacion del PIC32.
-
Me he leido el manual que explica la instalacion del driver y ya me funciona. :P
La verdad es que antes de preguntar hay que leer y releer bien, las prisas son malas consejeras.
Tengo que estudiar mucho como funciona este Kit que es muy diferente a lo que yo conocia.
Seria muy interesante que hicieramos un tema con ejemplos de programacion del PIC32.
Qué bueno que ya funciona.
Hay una carpeta de ejemplos en el directorio de instalación de C32. El kit que compraste también debe traer varios. Si tienes dudas de alguno los podemos checar en conjunto.
-
Hola, les agradezco que me puedan enviar una imagen del CD de Ethernet Starter Kit.
Ya que compre el dispositivo pero me vino sin CD
-
Lo mas seguro es que este en la pagina de microchip.
Te dejo el enlace (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2615&dDocName=en545713)
-
Alguno de ustedes ha utilizado el "PIC32 ESK TCPIP Demo"???? o le ha aparecido el error de la imagen q adjunto... estoy utilizando el PIC32 ethernet starter kit, me baje el "PIC32 ESK TCPIP Demo" de la pagina de Michrochip lo compile pero me salio ese error y no tengo ni idea de que seria.
-
Hola, el error ya esta solucionado, era el compilador que era muy vieja y no tenia esa funcion, lo actualice y listo, pero el MPLABX todavia como que tiene problema con el PIC32 ETHERNET STARTER KIT por que no le pude poner a hacer el debug, instale el MPlab 8.8 y funciono perfectamente, asi que me tocara seguir en el viejito :(
Se pueden tener varias conexiones con el stack TCPIP de microchip???
-
Si, ya me entere que si se podía, ademas lo probé y funciono, si alguien necesita la ayuda le expli con mucho gusto aunque todavia tengo una duda :D :D :D, ahora mi proximo paso es utilizar el USB de este modulo, alguien lo ha intentado???
-
Entre los mismos ejemplos de Microchips Solutions hay de USB, device y Host ;-)
-
si gracias, no los habia visto.. a trabajar :-/ :-/ :-/ :-/ :-/
-
:( me pospusieron el usb, ahora necesito conectarme como cliente tcp, busque en el archivo GenericTCPClient.c de microchip, y allí esta un ejemplo, lo pase a mi código, pero no se me conecta, aunque tampoco me dice que el socket sea invalido, miren mi código:
static BYTE ServerName[] = "111.111.124.1";
static DWORD Timer;
// Defines the URL to be requested by this HTTP client
//static ROM BYTE RemoteURL[] = "/search?as_q=Microchip&as_sitesearch=microchip.com";
__TCPNIMOCLIENT TCPNIMOClient;
void initnimotest(void){//Inicializador de la aplicacion nuestra
TCPNIMOClient.TCPNIMOSocket = TCPOpen((DWORD)&ServerName[0], TCP_OPEN_RAM_HOST, TCP_NIMO_PORT, TCP_PURPOSE_GENERIC_TCP_CLIENT);
if(TCPNIMOClient.TCPNIMOSocket==INVALID_SOCKET){
LED1_IO = 1;return;
}
LED2_IO = 1;
}
Si no funcionara me encendiera el led 1 pero el nunca lo enciendo solo el led 2, osea que el socket esta "bien", pero en mi servidor no veo conexión.... q podría ser????
-
Pero proba pidiendo datos al servidor y mostrarlo en el cliente ;-) Ahí al solicitar datos podes ver si ocurre algún inconveniente.
-
Ya lo intente, pero al servidor no le llega ninguna pregunta que le mande desde el cliente, así que la conexión no esta establecida, ya creo q me voy a volver loco :D
-
Ya me funcionoooooooooooooooooooo... ya se que era, estaba definiendo el puerto mal y no me había dado cuenta, yo lo tenia así:
#define TCP_NIMO_PORT 1572
Y el código de muestra lo tenia así
static WORD TCP_NIMO_PORT = 1572;
Lo cambie y me funciono perfectamente, así que otro problema mas resuelto, ahora mirare si se puede ser cliente y servidor al mismo tiempo.
-
Hola, yo he estado trabajando con el Stack TCPIP de Microchip, he trabajado con el archivo demo de microchip, ahora quiero armar yo mismo el stack por que con ese demo no puedo editar el stack ya que trae un archivo .a que no se puede editar, ahora bien, no he logrado compilar ese stack, siempre me sale un error, de algun lado distinto siempre me sale un error, quisiera saber si alguien me puede ayudar con esto o me puede pasar el proyecto compilado para poder editarlo y agregarle el programa que yo he hecho, gracias.
-
Que error te marca?
-
Bueno lo que hice fue que busque uno ya armado completamente y desde allí estoy trabajando, hasta ahora no había tenido problemas, pero ahora quise utilizar el servidor y cliente al mismo tiempo pero no me funciona, en el proyecto de ejemplo donde solamente esta el archivo .a (que creo que es una librería), si me funciona ya ya la verde me he leído eso pero no encuentro que sera lo que me hace falta, quisiera saber si a alguno le ha pasado eso y me puede ayudar, gracias.
-
Hola, quisiera saber si el stack tcp/ip de microchip funciona sin cristal???
-
Si a lo que te refieres es a utilizar el reloj interno a la velocidad necesaria para que corra el stack, deberia poderse hacer sin problema.
-
hasta ahora he estado probando con el reloj interno una rutina que me entregue datos por el uart, pero solo he podido llegar hasta 4800, no he podido llegar a 9600 con reloj interno y sin pll, si se puede llegar hasta los 9600??? si quieren puedo publicar mi codigo
-
En realidad si no activas el PLL y te vas bien arriba con los Mhz del micro, es casi imposible que logres buena sincronización en los envíos.
-
estoy probando con el pll y se me hace mas lenta la comunicacion :shock:
-
Si activaste el PLL, debes seleccionar un baudrate 4 veces mayor, o sea la configuración de la Uart debe ser cambiada a la de un cristal de frecuencia 4 veces mayor, se entiende??
Ejemplo: Si tu frecuencia interna elegida es de 4 Mhz y activas el PLL, el micro funcionara a 16Mhz reales, por lo tanto los cálculos de seteos de la Uart debes hacerlos por 16 Mhz
-
hola, mira, buscando en internet me di cuenta que me hacían falta dos fuses de configuración, los probé como vi el ejemplo y me funciono, aquí esta la pagina de donde lo tome y mi código:
Curso PIC32 Osciladores (http://www.aquihayapuntes.com/curso-pic32/osciladores-timer.html)
/*********************************************************************
*
* 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
// *****************************************************************************
// *****************************************************************************
// Section: Configuration bits
// SYSCLK = 80 MHz (8MHz Crystal/ FPLLIDIV * FPLLMUL / FPLLODIV)
// PBCLK = 40 MHz
// Primary Osc w/PLL (XT+,HS+,EC+PLL)
// WDT OFF
// Other options are don't care
// *****************************************************************************
// *****************************************************************************
/*#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = OFF
#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_1
#pragma config FWDTEN = OFF, POSCMOD = OFF, FNOSC = FRCPLL, CP = OFF, FPLLODIV = DIV_256
#pragma config FMIIEN = OFF, FETHIO = OFF, FPLLIDIV = DIV_12, FPLLMUL = MUL_15*/
#pragma config FNOSC = FRCPLL//Oscilador Interno con PPL
#pragma config POSCMOD = OFF //
#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
//SYSTEMConfigPerformance(80000000ul);
// *****************************************************************************
// *****************************************************************************
// Section: System Macros
// *****************************************************************************
// *****************************************************************************
/*
#define GetSystemClock() (2000000ul)
#define GetPeripheralClock() (GetSystemClock()/(1 << OSCCONbits.PBDIV))
#define GetInstructionClock() (GetSystemClock())
*/
#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_U3_TRIS (TRISAbits.TRISA4)
#define LED_Rx_U3 (LATAbits.LATA4)
#define LED_Tx_U3_TRIS (TRISAbits.TRISA3)
#define LED_Tx_U3 (LATAbits.LATA3)
#define LED_Tx_U1_TRIS (TRISAbits.TRISA2)
#define LED_Tx_U1 (LATAbits.LATA2)
void WriteString(const char *string);
int main(void)
{
OSCTUNbits.TUN=0;
OSCCONbits.COSC = 7;
DDPCONbits.JTAGEN=0;
LED_ON_OFF_TRIS = 0;
LED_Rx_U3_TRIS = 0;
LED_Tx_U3_TRIS = 0;
LED_Rx_U1_TRIS = 0;
LED_Tx_U1_TRIS = 0;
LED_Tx_U1 = 0;
LED_Rx_U1 = 0;
LED_Tx_U3 = 0;
LED_Rx_U3 = 0;
//U1MODEbits.BRGH=1;
//U1BRG=108;
// 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);
mPORTAClearBits(BIT_7); // Turn off RA7 on startup.
mPORTASetPinsDigitalOut(BIT_7); // Make RA7 as output.
// Explorer-16 uses UART1 to connect to the PC.
// This initialization assumes 36MHz Fpb clock. If it changes,
// you will have to modify baud rate initializer.
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);
// configure for multi-vectored mode
INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
// enable interrupts
INTEnableInterrupts();
// UARTSendDataByte(UART1, 0x3f);
WriteString("*** UART Interrupt-driven Application Example ***\r\n");
WriteString("*** Type some characters and observe echo and RA7 LED toggle ***\r\n");
while(1)
{
LED_Tx_U1 = 1;
DelayMs(100);
LED_Tx_U1 = 0;
DelayMs(100);
}
// Let interrupt handler do the work
while (1){LED_ON_OFF = 1;}
return 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);
}
}
}
// helper functions
void WriteString(const char *string)
{
while(*string != '\0')
{
while(!UARTTransmitterIsReady(UART1))
;
UARTSendDataByte(UART1, *string);
string++;
while(!UARTTransmissionHasCompleted(UART1))
;
}
}
//void PutCharacter(const char character)
void PutCharacter(char character)
{
while(!UARTTransmitterIsReady(UART1))
;
//if(character==0x09){LED_Rx_U1 = 1;}
UARTSendDataByte(UART1, character);
while(!UARTTransmissionHasCompleted(UART1))
;
}
// 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(UARTGetDataByte(UART1));
// Toggle LED to indicate UART activity
mPORTAToggleBits(BIT_7);
}
// We don't care about TX interrupt
if ( INTGetFlag(INT_SOURCE_UART_TX(UART1)) )
{
INTClearFlag(INT_SOURCE_UART_TX(UART1));
}
}
De verdad muchas gracias por la ayuda, voy a seguir probando, ahora que termine de probar el uart, voy a probar el ethernet con el cristal interno y creo que necesitare algunos ajustes, cuando se termine y funcione ese codigo tambien se subira :-/ :-/ :-/
-
Interesante, no sabia que estabas con el PIC32...
Cuanto mas info puedas aportar mejor, es una materia pendiente que tengo... :mrgreen: :mrgreen:
-
claro MGLSOFT, de casualidad mira lo que me pasa ahora, yo tengo una board que tiene el ethernet, dos usb pero funcionan como cdc por medio de un driver, dos puertos rs232, 6 entradas análogas, 5 salidas digitales y 5 entradas digitales, fue un primer experimento y tiene sus errores :D. esta utilizando un PIC32MX795F512L, lo primero que estaba haciendo era probar los uart, pero no me funcionaron ya que los fuses estaban para utilizar cristal y cristal no tengo, ahora que ya se configuro estoy ordenando el código que monte ahorita y cuando termine que fui a compilar me sale error en la interrupción del uart 3, yo lo configure exactamente igual a como estaba configurado el uart 1 pero me dice esto:
source\uart_interrupt.c:271:1: error: Vector number must be an integer between 0 and 63
entonces es hora de resolver un nuevo problema :o :D ... tambien me ha sorprendido que el pic32 tiene uart a y b y no tengo ni idea de como se configuran los b, los uart que tengo yo implementado con los uart 1 y 3 a,a ver si tienes idea de esto.
-
Si colocas _UARTx_VECTOR (reemplazar x), no funciona? Ayuda utilizar el Help de C32 ;-)
-
Nada Suky, me sale error, mira
// 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(UARTGetDataByte(UART1));
}
// We don't care about TX interrupt
if ( INTGetFlag(INT_SOURCE_UART_TX(UART1)) )
{
INTClearFlag(INT_SOURCE_UART_TX(UART1));
}
}
// UART 3 interrupt handler
// it is set at priority level 2
void __ISR(_UART3_VECTOR, ipl2) IntUart3Handler(void)
{
LED_Rx_U3 = 1;
// Is this an RX interrupt?
if(INTGetFlag(INT_SOURCE_UART_RX(UART3)))
{
// Clear the RX interrupt Flag
INTClearFlag(INT_SOURCE_UART_RX(UART3));
// Echo what we just received.
PutCharacter(UARTGetDataByte(UART3));
}
// We don't care about TX interrupt
if ( INTGetFlag(INT_SOURCE_UART_TX(UART3)) )
{
INTClearFlag(INT_SOURCE_UART_TX(UART3));
}
}
en el uart1 pasa bien, pero en el uart3 me sale este error:
source\uart_interrupt.c:246:1: error: Vector number must be an integer between 0 and 63
-
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!
-
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.
/*********************************************************************
*
* 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);}
-
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.
-
Un pequeño paso para el hombre, pero uno grande para el foro !!! ((:-)) ((:-)) ((:-)) ((:-)) ((:-))
-
Si, bastante grande, gracias al foro.
-
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]