Il pic18f46k22 è collegato tramite il pin 25(TX1) al RX del convertitore seriale-usb (nel mio caso il pin RB7 di un pic18f14k5) e ip pin 26(RX1) al TX del convertitore (RB5).
Ma per fortuna il problema era softwere, ora la funzione echo funziona, ho copiato e riadattato il codice in questa discussione http://www.microchip.com/forums/tm.aspx?m=647984
Non ho ben capito cosa sbagliavo va mesto funziona:
- Codice: Seleziona tutto
#include <stdint.h> /* For uint8_t definition */
#include <stdbool.h> /* For true/false definition */
#include <usart.h>
#include "system.h" /* System funct/params, like osc/peripheral config */
#include "user.h" /* User funct/params, such as InitApp */
void main(void)
{
char ch;
TRISCbits.TRISC7 = 1; //Defining as per datasheet requirement
TRISCbits.TRISC6 = 1; //Defining as per datasheet requirement
ADCON0bits.ADON = 0;
ANSELCbits.ANSC7 = 0; //0 = Digital input buffer enabled
ANSELCbits.ANSC6 = 0; //0 = Digital input buffer enabled
// 19200 bps 8 bit + 1 stop
Open1USART( USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,
207 );
while (1)
{
while (!DataRdy1USART());
ch = Read1USART();
Write1USART(ch);
while (Busy1USART());
// putc1USART(getc1USART());
}
}
Grazie mille.
Un ultima domanda, questo è il file interrupt.c dei template che crea mplabx
- Codice: Seleziona tutto
/******************************************************************************/
/*Files to Include */
/******************************************************************************/
#if defined(__XC)
#include <xc.h> /* XC8 General Include File */
#elif defined(HI_TECH_C)
#include <htc.h> /* HiTech General Include File */
#elif defined(__18CXX)
#include <p18cxxx.h> /* C18 General Include File */
#endif
#if defined(__XC) || defined(HI_TECH_C)
#include <stdint.h> /* For uint8_t definition */
#include <stdbool.h> /* For true/false definition */
#endif
/******************************************************************************/
/* Interrupt Routines */
/******************************************************************************/
/* High-priority service */
#if defined(__XC) || defined(HI_TECH_C)
void interrupt high_isr(void)
#elif defined (__18CXX)
#pragma code high_isr=0x08
#pragma interrupt high_isr
void high_isr(void)
#else
#error "Invalid compiler selection for implemented ISR routines"
#endif
{
/* This code stub shows general interrupt handling. Note that these
conditional statements are not handled within 3 seperate if blocks.
Do not use a seperate if block for each interrupt flag to avoid run
time errors. */
#if 0
/* TODO Add High Priority interrupt routine code here. */
/* Determine which flag generated the interrupt */
if(<Interrupt Flag 1>)
{
<Interrupt Flag 1=0>; /* Clear Interrupt Flag 1 */
}
else if (<Interrupt Flag 2>)
{
<Interrupt Flag 2=0>; /* Clear Interrupt Flag 2 */
}
else
{
/* Unhandled interrupts */
}
#endif
}
/* Low-priority interrupt routine */
#if defined(__XC) || defined(HI_TECH_C)
void low_priority interrupt low_isr(void)
#elif defined (__18CXX)
#pragma code low_isr=0x18
#pragma interruptlow low_isr
void low_isr(void)
#else
#error "Invalid compiler selection for implemented ISR routines"
#endif
{
/* This code stub shows general interrupt handling. Note that these
conditional statements are not handled within 3 seperate if blocks.
Do not use a seperate if block for each interrupt flag to avoid run
time errors. */
#if 0
/* TODO Add Low Priority interrupt routine code here. */
/* Determine which flag generated the interrupt */
if(<Interrupt Flag 1>)
{
<Interrupt Flag 1=0>; /* Clear Interrupt Flag 1 */
}
else if (<Interrupt Flag 2>)
{
<Interrupt Flag 2=0>; /* Clear Interrupt Flag 2 */
}
else
{
/* Unhandled interrupts */
}
#endif
}
Io ho capito i vari #if defined variano al variare del compilatore, ma cosa fa quando legge #if 0 e chiude con #endif.
Grazie ancora Ciao Ivo

Elettrotecnica e non solo (admin)
Un gatto tra gli elettroni (IsidoroKZ)
Esperienza e simulazioni (g.schgor)
Moleskine di un idraulico (RenzoDF)
Il Blog di ElectroYou (webmaster)
Idee microcontrollate (TardoFreak)
PICcoli grandi PICMicro (Paolino)
Il blog elettrico di carloc (carloc)
DirtEYblooog (dirtydeeds)
Di tutto... un po' (jordan20)
AK47 (lillo)
Esperienze elettroniche (marco438)
Telecomunicazioni musicali (clavicordo)
Automazione ed Elettronica (gustavo)
Direttive per la sicurezza (ErnestoCappelletti)
EYnfo dall'Alaska (mir)
Apriamo il quadro! (attilio)
H7-25 (asdf)
Passione Elettrica (massimob)
Elettroni a spasso (guidob)
Bloguerra (guerra)


