SCI interrupt in assembly

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SCI interrupt in assembly

1,303 Views
coolcatt
Contributor I

Hey guys,

 

I am trying to interface with a C328 UART camera, and I'm running into some problems.

 

I have it hooked up and the first step is to send an SYNC message.  I do that fine and i start to receive the ACK message.  I got the first byte (0xAA), but then the next byte is supposed to be 0x0F or 0x0E, followed by 4 bytes of 0x00.  My problem is that after i receive the AA, i only get 3 of the other bytes and they are all 0x00.  Does this mean that it is overwriting the second byte before I obtain it?  I have tried it at 14,400 and 115,200 but get the same results.

 

Here are my thoughts:  I do not have interrupt routines, i just monitor the appropriate bit to see if the receive buffer has any information for me.  I receive the byte, then print it in hex to the HyperTerminal to verify the value.  Am i doing too much in between receiving this?

 

Should I set it up so that the interrupt routine will get the value and store it in a buffer until it gets the entire command then process it? 

 

I am programming it in assembly and i am also not familiar with how to do the interrupt service routines.  I have used the mc9s12c32 and can use those interrupt service routines, but I am not sure how to do it as far as initializing the routine because it seems to follow a different format/process.

 

Any comments would be greatly appreciate :smileyhappy:

 

Thanks

Labels (1)
0 Kudos
Reply
2 Replies

578 Views
hotwolf
Contributor II

Coolcatt,

If your SCI transmission problems are not caused by a RX buffer overrun, then you could also check how exactly you match the target baud rate. I don't know the C328 hardware, but I've made the experience that some USB-RS232 adapters are very sensitive to deviations of the baud rate. 

 

 

If you would like to to see an example of an SCI ISR written in assembly,  have a look at this:

 

http://github.com/hotwolf/S12CBase

 

It's a basic application framework for the S12C32/S12C128 that I just happend to post two days ago. It's all written in assembly and it has fully interrupt driven SCI RX/TX routines.

 

 

0 Kudos
Reply

578 Views
bigmac
Specialist III

Hello,

 

I suspect that you have a receive overrun condition.  On the receipt of each byte of a data packet, the processing of the data must be kept to absolute minimum.  Normally, each received byte would be written to a FIFO or "circular" buffer, with very little other processing allowed.  This should be done within an ISR.

 

The duration of this process becomes far more important for higher baud rates.  In fact a baud rate of 115200 baud may prove to be too high, leaving a maximum period of less than 86 microseconds for handling each byte, especially if other interrupts should occur at a critical point (just prior to the SCI receive interrupt occurring).

 

The contents of the buffer would usually be interrogated and processed from within the main loop code.

 

In essence, the ISR code will be similar to other sub-routines, but its start address would be programmed at the appropriate location in the vector table, and it should finish with the RTI instruction.  Always ensure that the interrupt flag for the peripheral module is cleared before exiting the ISR.

 

Regards,

Mac

 

0 Kudos
Reply