Hi people,
I'm getting my first steps on USB lane and I'm having the same troubles as USBpro.
I've compiled two examples given on this forum and thy did not work any way.
The problem still the same: PC (windoes) does not recognize the microcontroller usb port.
Details:
MikroC 8.2 version
Microcontroller: PIC18F2550
HS Quarz freq: 12 M
Selected configuration words: (only values turned ON)
1L:
PLLDIV_3 -->To obtain 4MHz from 12MHz Quarz
USBDIV_2 ---> able to clock transceiver from 96MHz by 2
1H:
FOSC_HSPLL_HS
FCMEM_ON
IESO_ON
2L:
PWRT_OFF
BOR_ON_ACTIVE
BORV_43
VREGEN_ON
2H:
WDT_OFF
3H & 3L:
MCLRE_ON
LPT1OSC_OFF
PBARDEN_OFF
CCP2MX_OFF
4L:
STVREN_OFF
LVP_OFF
ICPRT_OFF
XINST_OFF
DEBUG_OFF
The other words remain as is.
And here is the code I´ve tried, taken from a "working" example in the forum and with some modifications done by me (basically on MCU ports configuration).
___________________________________________
#include "USB_New"
unsigned char Read_buffer[64];
unsigned char Write_buffer[64];
unsigned char num, Flags;
/* Timer interrupt service routine */
void interrupt()
{
HID_InterruptProc(); /* Keep alive */
}
/* Start of MAIN program */
void main()
{
/* Disable all interrupts */
INTCON = 0; /* Disable GIE, PEIE, TMR0IE,INT0IE,RBIE */
INTCON2 = 0xF5;
INTCON3 = 0xC0;
RCON.IPEN = 0; /* Disable Priority Levels on interrupts */
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
/* Ports Configuration */
PORTA=0;
ADCON0=0x0; /* A/D disconnected. */
CMCON =0x7;
ADCON1=0x0F; /* Port A is a Digital port */
TRISA=0; /*Port A as output */
PORTB=0;
TRISB=0x01; /* PB0 - EXT interruption IN. All the other pins programmed as outputs*/
//INTCON=0x90; /* GIE=1, PEIE=0, INT0IE=1*/
//INTCON2=0x80; /* All PB pull-up disable, INT0 ocurres on falling edge */
PORTC=0;
UCON.F3=1; /* RC4 and RC5 configured as DI and USB module was enabled */
UCFG.F3=0; /* On-chip USB transceiver was enabled */
TRISC=0x0; /* RC7..RC4 were configured as DI, the other pins as outputs */
Flags=0x03; /* Mute-Disabled, ZCross-Enabled */
PORTB.F7=1; /* Mute - Disable */
PORTB.F6=1; /* Zero Crossing - Enable */
PORTB.F5=1; /* CS signal - Disable */
Hid_Enable(&Read_buffer, &Write_buffer);
Delay_ms(250);
Delay_ms(250);
// Read from the USB port. Number of bytes read is in num
while(1)
{
num = Hid_Read();
if(num > 0){
if((Read_buffer[0] == 'P') && (Read_buffer[1] == '=') &&
(Read_buffer[2] == '?') && (Read_Buffer[3] == '?'))
{
PORTA.F0 = 0x01;
Write_buffer[0] = 'P'; Write_buffer[1] = '=';
Write_buffer[2] = 'T'; Write_buffer[3] = 'T';
Write_buffer[4] = 'A';Write_buffer[5] = 'R';
Hid_Write(&Write_buffer,6);
}
}
delay_ms(80);
PORTA.F0 = 0;
num = 0;
} //end while (1)
Hid_Disable();
}//end miain
¿Somebody could tell me what´s wrong here?
Also I want to ask for information about how the HID terminal works. Indeed on the MikroC 8.2 HELP nothing is written.
Thanks a lot,
Black Bird