Hola! Sigo por aquí para no abrir un nuevo hilo.
Despues de tener todo el programa 100% operativo, he decidido migrar de CCS Compiler a MPLAB XC8. Las razones, entre otras, son que puedo compartir el código con un compañero a través de la nube y puede editarlo desde la aplicación online de MPLAB, y que además, a priori, me ofrece más opciones para debuggear, ya que con CCS Compiler nunca he conseguido que se conecte con PicKit 3.
El caso es que MPLAB me esta defraudando, con to "ortopédico", lioso y problemático que es, sin hablar de que no encuentro funciones básicas como delay_ms, pero eso ya lo resolveré más adelante.
El caso es que consigo que el PC detecte el PIC, pero no recibe nada de nada, y no se por qué. Mirando por internet, cada uno usa una función diferente, y en el AN1164 de Microchip usa unas funciones que diría que ya ni existen.
El caso es que no paro de probar opciones y no hay manera de dar con la tecla. Con lo directo que es con CCS (quién lo diría..)
Os dejo el código por si alguien ve qué puede estar pasando:
// main.c#include "mcc_generated_files/mcc.h"
/*
Main application
*/
void main(void)
{
// initialize the device
SYSTEM_Initialize();
// When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
// Use the following macros to:
// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable();
// Enable the Peripheral Interrupts
INTERRUPT_PeripheralInterruptEnable();
// Disable the Global Interrupts
//INTERRUPT_GlobalInterruptDisable();
// Disable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptDisable();
while (1)
{
putsUSBUSART("hola");
}
}
// mcc.c#include "mcc.h"
void SYSTEM_Initialize(void)
{
PIN_MANAGER_Initialize();
OSCILLATOR_Initialize();
USBDeviceInit();
USBDeviceAttach();
}
void OSCILLATOR_Initialize(void)
{
OSCCON = 0x3C;
OSCTUNE = 0x05;
ACTCON = 0x98;
BORCON = 0x80;
while(PLLRDY == 0)
{
}
}
// pin_manager.c#include "pin_manager.h"
void PIN_MANAGER_Initialize(void)
{
/**
LATx registers
*/
LATA = 0x00;
LATC = 0x08;
/**
TRISx registers
*/
//TRISA = 0x30;
TRISC = 0x37;
/**
ANSELx registers
*/
ANSELC = 0x00;
ANSELA = 0x00;
/**
WPUx registers
*/
WPUA = 0x00;
OPTION_REGbits.nWPUEN = 1;
/**
APFCONx registers
*/
APFCON = 0x00;
}
//interrupt_manager.c#include "interrupt_manager.h"
#include "mcc.h"
void __interrupt() INTERRUPT_InterruptManager (void)
{
// interrupt handler
if(INTCONbits.PEIE == 1)
{
if(PIE2bits.USBIE == 1 && PIR2bits.USBIF == 1)
{
USB_USBDeviceTasks();
}
else
{
//Unhandled Interrupt
}
}
else
{
//Unhandled Interrupt
}
}
/**
End of File
*/
Gracias de antemano!
