2006-02-21 09:57 PM
2006-02-21 09:57 PM
hello to all,
it is my first post that shipment. I have a problem with the ST9 F120, I am trying to create a software that to every data received on the serial me kinds a interrupt. I have connected the ST9 to a hyperterminal I am through SCI1(9,1,9,0), SCI0(5,2,5,1); digit on hyperterminal the SCI0 I would want that it generated a interrupt and that me correspondent to SCI1 wrote the characters on an other hyperterminal but unfortunately this does not happen could even help me with a small code of example? I enclose you mine more soon main and rows SCI.C aspect to yours news thanks MAIN.C void main(void) { di(); INIT_PLL(); INIT_SCI(); INIT_SCI1(); INIT_SCI_IT(); ei(); spp(P0C_PG); P0C2R = 0x00; P0C1R = 0xFF; P0C0R = 0x00; P0DR&=0; while(1) { INIT_SCI_IT(); ei(); spp(P0C_PG); P0DR &= 0x0; P0DR ^= 0x2; spp(SCI0_PG); ToRec=S_RXBR; if (ToRec != temp) { spp(SCI1_PG); S_TXBR=ToRec; temp=ToRec; } } spp(P0C_PG); P0DR ^= 0x80; } SCI.C #include ''sci.h'' #include #include ''io_port.h'' #include ''define.h'' #include ''device.h'' #include ''ioinit.h'' #include ''string.h'' unsigned char ToReceive; unsigned int c=0; void INIT_SCI(void) { spp(SCI0_PG); S_BRGHR = (unsigned char)((SCI_BRGENERATOR & 0xFF00)/256); S_CHCR = SCI_CHAR; S_CCR = SCI_MORECLOCK; /*CCR register: TXCLK = OCLK = XRX = CD = 0 */ S_ISR = 0; S_IDPR = 0; S_BRGLR = (unsigned char)(SCI_BRGENERATOR & 0x00FF); IN_TTL(PORT_SCI0_IN, PIN_SCI0_IN); OUT_AFPP(PORT_SCI0_OUT, PIN_SCI0_OUT); } void INIT_SCI1(void) { spp(SCI1_PG); S_BRGHR = (unsigned char)((SCI_BRGENERATOR & 0xFF00)/256); S_CHCR = SCI_CHAR; S_CCR = SCI_MORECLOCK; /*CCR register: TXCLK = OCLK = XRX = CD = 0 */ S_ISR = 0; S_IDPR = 0; S_BRGLR = (unsigned char)(SCI_BRGENERATOR & 0x00FF); IN_TTL(PORT_SCI1_IN, PIN_SCI1_IN); OUT_AFPP(PORT_SCI1_OUT, PIN_SCI1_OUT); } void INIT_SCI_IT(void) { spp(SCI0_PG); S_IVR = (IT_SCI_VECT & 0xF8); S_IDPR &= SCI_MASK; S_IDPR |= PRIO_SCI; S_IMR &= SCI_MASK; S_IMR |= Sm_rxdi; } #pragma interrupt INTSCI_Receive void INTSCI_Receive(void) { #ifdef NO_SAVE_RESTORE_PPR_IN_IT SAVE_PAGE; #endif spp(SCI0_PG); ToReceive=S_RXBR; spp(SCI1_PG); S_TXBR=ToReceive; spp(SCI0_PG); S_IMR &= ~Sm_rxa; S_ISR &= ~Sm_rxap; /*clear pending bits*/ S_IMR &= ~Sm_rxdp; #ifdef NO_SAVE_RESTORE_PPR_IN_IT RESTORE_PAGE; #endif di(); }