cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Smart Bluetooth

Anonymous
Not applicable

I'm looking to set a characteristic when a value is entered into a com port while the chip is hooked up via USB. I can't find documentation that tells me how to handle a puart rx interrupt. Does anyone know how to do this?

0 Likes
1 Solution
Anonymous
Not applicable

I did have some luck! After digging through numerous threads I found what I needed. In your application init function you need to enable interrupts and set the callback, which is done with this code:

puart_init();

bleapputil_cpuIntEnable(0);

P_UART_WATER_MARK_RX_LEVEL (1);

puart_rxCb = application_puart_interrupt_callback;

puart_enableInterrupt();

puart_rxCb is the callback upon puart receiving data (Like from a com port). You define a function for handling the interrupt and then sett the callback to be that function. I did however find that a few lines of code were needed to continue to receive interrupts:


P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;

This seems to clear the interrupt. However, the interrupt fires whenever the puart in buffer has data, so if you don't consume it all in your callback, the interrupt will fire again immediately. You can consume the buffer one byte at a time using puart_read(<pointer to memory to read to>).

View solution in original post

0 Likes
4 Replies
MichaelF_56
Moderator
Moderator

This thread, and the others linked to within it contain a tremendous amount of low level information on how the PUART can be managed from a code perspective: What are the PUART FIFO Rx interrupt threshold settings?

0 Likes
Anonymous
Not applicable

swelan

Any luck with your PUART?

0 Likes
Anonymous
Not applicable

I did have some luck! After digging through numerous threads I found what I needed. In your application init function you need to enable interrupts and set the callback, which is done with this code:

puart_init();

bleapputil_cpuIntEnable(0);

P_UART_WATER_MARK_RX_LEVEL (1);

puart_rxCb = application_puart_interrupt_callback;

puart_enableInterrupt();

puart_rxCb is the callback upon puart receiving data (Like from a com port). You define a function for handling the interrupt and then sett the callback to be that function. I did however find that a few lines of code were needed to continue to receive interrupts:


P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;

This seems to clear the interrupt. However, the interrupt fires whenever the puart in buffer has data, so if you don't consume it all in your callback, the interrupt will fire again immediately. You can consume the buffer one byte at a time using puart_read(<pointer to memory to read to>).

View solution in original post

0 Likes
Anonymous
Not applicable

Thanks for sharing!

0 Likes