cancel
Showing results for 
Search instead for 
Did you mean: 

STR750 UART Rx Interrupt

synsless
Associate II
Posted on March 27, 2008 at 12:07

STR750 UART Rx Interrupt

4 REPLIES 4
synsless
Associate II
Posted on March 24, 2008 at 00:35

I'm having some trouble activating the ISR for receiving information on UART0.

I have an RS232 UPC scanner that I want to receive data from. I tried modifying some of the examples to set everything up but I can't get it to work, I'm not even 100% sure its a software problem. At this point I dont really care whats done with the data, I just want the interrupt to trigger correctly so I've just put a while(1) statement in the interrupt so the program stays there if it gets there.

I have a few ideas of what could be going wrong, my first guess being the voltages coming off the scanner aren't what they should be. I can't check this right now but I will tomorrow. The way this is setup now I believe a 1 should be about 3.3v (IOVoltageSetup)... There could also be any number of coding problems, of course. I'm hoping someone will look over my code real quick and let me know if anything is setup wrong or I've done something stupid.

Oh, just to verify, the interrupt is triggered when the receive pin (which should be held at 1) drops to 0, correct?

Thanks for the help! This is my first time using an ARM so I've got quite a learning curve to climb =)

Heres what I have so far:

int main()

{

#ifdef DEBUG

debug();

#endif

/* Configure the system clocks */

MRCC_Configuration();

/* Configure the GPIO ports */

GPIO_Configuration();

/* UART0 configuration ---------------------------------------------*/

/* UART0 configured as follow:

- Word Length = 8 Bits

- One Stop Bit

- No parity

- BaudRate = 9600 baud

- Hardware flow control disabled (RTS and CTS signals)

- Receive enabled

- Receive and transmit FIFOs are enabled

- Receive FIFO level have 2 bytes depth

*/

UART_InitStructure.UART_WordLength = UART_WordLength_8D;

UART_InitStructure.UART_StopBits = UART_StopBits_1;

UART_InitStructure.UART_Parity = UART_Parity_No ;

UART_InitStructure.UART_BaudRate = 9600;

UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;

UART_InitStructure.UART_Mode = UART_Mode_Rx;

UART_InitStructure.UART_FIFO = UART_FIFO_Enable;

UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_8; /* FIFO size 16 bytes, FIFO level 2 bytes */

/* Configure UART0 */

UART_Init(UART0, &UART_InitStructure);

/* Enable UART0 Receive and Transmit interrupt */

UART_ITConfig(UART0, UART_IT_Receive, ENABLE);

/* Configure and enable the interrupt controller */

EIC_Configuration();

/* Enable UART0 */

UART_Cmd(UART0, ENABLE);

while (1);

}

void MRCC_Configuration(void)

{

/* MRCC system reset(for debug purpose) */

MRCC_DeInit();

/* Wait for OSC4M start-up */

OSC4MStartUpStatus = MRCC_WaitForOSC4MStartUp();

if(OSC4MStartUpStatus == SUCCESS)

{

/* Set HCLK to 30 MHz */

MRCC_HCLKConfig(MRCC_CKSYS_Div2);

/* Set CKTIM to 30 MHz */

MRCC_CKTIMConfig(MRCC_HCLK_Div1);

/* Set PCLK to 30 MHz */

MRCC_PCLKConfig(MRCC_CKTIM_Div1);

/* Set CKSYS to 60 MHz */

MRCC_CKSYSConfig(MRCC_CKSYS_OSC4MPLL, MRCC_PLL_Mul_15);

}

/* GPIO pins optimized for 3V3 operation */

MRCC_IOVoltageRangeConfig(MRCC_IOVoltageRange_3V3);

/* Enable GPIO, UART0 and UART2 Clocks */

MRCC_PeripheralClockConfig(MRCC_Peripheral_GPIO | MRCC_Peripheral_UART0 |

MRCC_Peripheral_UART2, ENABLE);

}

void GPIO_Configuration(void)

{

GPIO_InitTypeDef GPIO_InitStructure;

/* Configure UART0_Rx and UART2_Rx pins as input floating */

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_24;

GPIO_Init(GPIO0, &GPIO_InitStructure);

}

void EIC_Configuration(void)

{

EIC_IRQInitTypeDef EIC_IRQInitStructure;

/* Configure and enable UART0_IRQChannel */

EIC_IRQInitStructure.EIC_IRQChannel = UART0_IRQChannel;

EIC_IRQInitStructure.EIC_IRQChannelPriority = 1;

EIC_IRQInitStructure.EIC_IRQChannelCmd = ENABLE;

EIC_IRQInit(&EIC_IRQInitStructure);

/* Enable the interrupt controller */

EIC_IRQCmd(ENABLE);

}

void UART0_IRQHandler(void)

{

while(1);

}

jpeacock2
Associate II
Posted on March 25, 2008 at 12:26

I'd suggest you first determine data is being sent to the UART from your scanner. Get an RS-232 breakout box and see if data is being sent to the STR750.

Enable the transmitter and see if you can send data out. Loop output to input and see if you receive what you send. This will test your RS-232 transceiver. You might want to try polled mode first (simple examples are in the ST library for the STR750) to verify the hardware is working.

How is the UART interrupt being vectored? You didn't show the code that handles the interrupt request and generates the vector from the EIC. You may not be getting to your interrupt handler at all, which would explain why you don't see the ISR triggering.

Are you aware that with FIFO mode enabled an interrupt only occurs when the watermark on the FIFO is reached? You may want to enable the timeout feature too, so an interrupt occurs if data sits in the FIFO too long.

synsless
Associate II
Posted on March 26, 2008 at 20:06

Got it to work, was a hardware problem with the scanner. Now I'm going to try what you suggested, transmitting what the board receives using the examples from the library.

Thanks for the info on the FIFO, now that the interrupt is working I'll need to do some reading on how to handle the data. I'll need to store several scans worth of data to transmit later, any suggestions on the best way to store it?

I'm new to ARM uCs (and I've got little more experience in uC programming in general), so thanks for the help and patience. I'm not new to programming, however, so I should understand any concepts 🙂

jpeacock2
Associate II
Posted on March 27, 2008 at 12:07

If you don't have enough room in RAM, or you need to persist the scans across a reset/power failure, then you might want to look at a large capacity serial NAND flash. Low pin count, but the tradeoff is speed, wear leveling and ECC error checking. Take a look at the SMI interface on the STR750. ST has some flash parts to go with it.

I use a 256Kbit Ramtron FRAM to store a transaction log while the STR750 is running so that I can recover to the last known state after resets. If 32Kbytes is large enough (and I believe Ramtron now has a 1Mbit part) then you might want to look at this part for external storage. Faster than flash since there's no erase time and a very high cycle count, so no wear leveling either.