View previous topic :: View next topic |
Author |
Message |
Franz Guest
|
enable_interrupt(global) PROBLEM! |
Posted: Wed Apr 14, 2004 9:36 am |
|
|
I use 2 serial in my Pic 16f876 :
The first is hardware the second is software for PRINTER.
My program is:
/* -----------------------------------------------------------------------
Inizializzazione Dispositivo Pic
--------------------------------------------------------------------------*/
void initDevice (void)
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_32);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,WDT_2304MS);//576MS
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8); // Tick 8us
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
enable_interrupts(INT_RDA);
enable_interrupts(INT_TIMER1);
enable_interrupts(global);
set_tris_a (IO_PORTA) ;
set_tris_b (IO_PORTB) ;
set_tris_c (IO_PORTC) ;
}
//////////////////////////////////
void initPrn (uchar col) //inizializza stampante
{
disable_interrupts( global );
// tempo di attesa necessario per reset stampante
delay_ms(2000);
// seleziona colonne (0x69 x40col / 0x49 x24col)
if (col == 40)
{
putc (0x1B) ;
putc (0x69) ;
}
else if (col == 24)
{
putc (0x1B) ;
putc (0x49) ;
}
// seleziona la modalità di stampa capovolto
putc (0x1b) ;
putc (0x52) ;
enable_interrupts (global);
}
/////////
void main ( void )
{
initDevice () ;
initPrn (24);
..........
Why if I call the function initPrn(24), the device not answer at the serial interrupt ( INT_RDA )?
( I must use disable_interrupts ( global ) and enable_interrupts( global );
because the routines is software and it isn't always correct).
Thanks and sorry for my BAD ENGLISH . |
|
|
DragonPIC
Joined: 11 Nov 2003 Posts: 118
|
When? |
Posted: Wed Apr 14, 2004 10:11 am |
|
|
INT_RDA does not work after initPrn (24); has returned? Global enables or disables any and all interrupts. Have you used #USE RS232? Some of your code seems to be missing.
If you have 2 RS232 ports, you need a steam. See fgetc() and fputc
() in user manual.
and configure each port separately using:
#USE RS232 (baud=9600,xmit=pin,rcv=pin,stream=COM)
stream is to identify each port. |
|
|
Franz Guest
|
I use 232 |
Posted: Fri Apr 16, 2004 7:32 am |
|
|
Yes my funcion return in the main.
Yes i write #USE RS232 for configure each port separately but I don't USE stream. But i don't understand the manual, I write only 1 o two byte not a long string. |
|
|
|