ADC Debug on LPC1114 erratic readings

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

ADC Debug on LPC1114 erratic readings

377 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Jakub16 on Sat Sep 21 10:16:58 MST 2013
Hello,

I am having erratic ADC readings in Console while in Debug mode. Sample readings:
 0 2.81V |##########################################       |
 0 2.21V |################################                 |
                 |
 0 1.39V |####################                             |
 1.08V |###############                                  |
 0 0.96V |#############                                    |
 0.78V |##########                                       |
 0 0.64V |########                                         |
 0.67V |########                                         |
 0 0.60V |#######                                          |
             |
 0 0.65V |########                                         |
4V |######                                           |
 0 0.63V |########                                         |
 0.55V |#######                                          |
 0 0.60V |#######                                          |
 0.53V |######                                           |
 0 0.53V |######                                           |
         |
 0 0.64V |########                                         |
######                                           |
 0 0.58V |#######                                          |
 0.63V |########                                         |
 0 0.55V |#######                                          |
 0.61V |#######                                          |
 0 0.57V |#######                                          |
     |
 0 0.59V |#######                                          |
##                                           |
 0 0.54V |######                                           |
 0.61V |########                                         |
 0 0.59V |#######                                          |
 0.59V |#######                                          |
 0 0.59V |#######                                          |
 |
 0 0.53V |######                                           |
                                         |
 0 0.56V |#######                                          |
 0.53V |######                                           |
 0 0.61V |#######                                          |
 0.50V |######                                           |
 0 0.62V |########                                         |

 0 0.60V |#######                                          |
                                     |
 0 0.54V |######                                           |
 0.62V |########                                         |  
 0.0.50V |######                                           |
 0.61V |#######                                          |
 0 0.61V |########                                         |

 0 0.59V |#######                                          |
                                 |
 0 0.56V |#######                                          |
 0.53V |######                                           |  
 0 0.60V |#######                                          |
 0.59V |#######                                          |
 0 0.53V |######                                           |

 0 0.50V |######                                           |
                             |
 0 0.63V |########                                         |
 0.56V |#######                                          |  
 0 0.58V |#######                                          |
 0.61V |########                                         |
 0 0.53V |######                                           |

 0 0.50V |######                                           |
                         |
 0 0.60V |#######                                          |
 0.62V |########                                         |  
 0 0.50V |######                                           |
 0.58V |#######                                          |
 0 0.61V |#######                                          |

 0 0.56V |#######                                          |
                     |
 0 0.58V |#######                                          |
 0.63V |########                                         |  
 0 0.50V |######                                           |
 0.62V |########                                         |
 0 0.56V |#######                                          |
 0 0.60V |#######                                          |
 0 0.61V |########                                         |
                 |
 0 0.53V |######                                           |
 0.60V |#######                                          |
 0 0.51V |######                                           |
 0.59V |#######                                          |
 0 0.62V |########                                         |
 0.52V |######                                           |
 0 0.60V |#######                                          |
             |
 0 0.58V |#######                                          |
5V |#######                                          |
 0 0.60V |#######                                          |
 0.61V |########                                         |
 0 0.52V |######                                           |
 0.60V |#######                                          |
 0 0.52V |######                                           |
         |
 0 0.62V |########                                         |
######                                           |
 0 0.55V |#######                                          |
 0.63V |########                                         |
 0 0.59V |#######                                          |
 0.58V |#######                                          |
 0 0.60V |#######                                          |
     |
 0 0.60V |#######                                          |
##                                           |
 0 0.60V |#######                                          |
 0.54V |######                                           |
 0 0.57V |#######                                          |
 0.51V |######                                           |
 0 0.56V |#######                                          |
 |
 0 0.49V |######                                           |
                                         |
 0 0.51V |######                                           |
 0.50V |######                                           |
 0 0.63V |########                                         |
 0.54V |######                                           |
 0 0.57V |#######                                          |

 0 0.56V |#######                                          |
                                     |
 0 0.57V |#######                                          |
 0.56V |#######                                          |  
 0.0.56V |#######                                          |
 0.54V |######                                           |
 0 0.59V |#######                                          |

 0 0.57V |#######                                          |
                                 |
 0 0.55V |#######                                          |
 0.59V |#######                                          |  
 0 0.52V |######                                           |
 0.56V |#######                                          |
 0 0.59V |#######                                          |

 0 0.57V |#######                                          |
                             |
 0 0.56V |#######                                          |
 0.59V |#######                                          |  
 0 0.57V |#######                                          |
 0.56V |#######                                          |
 0 0.60V |#######                                          |

 0 0.55V |#######                                          |
                         |
 0 0.60V |#######                                          |
 0.63V |########                                         |  
 0 0.62V |########                                         |
 0.69V |#########                                        |
 0 0.67V |########                                         |

 0 0.46V |#####                                            |
                     |
 0 0.60V |#######                                          |
 0.63V |########                                         |  
 0 0.59V |#######                                          |
 0.59V |#######                                          |
 0 0.58V |#######                                          |
 0 0.55V |#######                                          |
 0 0.57V |#######                                          |
                 |
 0 0.59V |#######                                          |
 0.56V |#######                                          |
 0 0.58V |#######                                          |
 0.59V |#######                                          |
 0 0.59V |#######                                          |
 0.55V |#######                                          |
 0 0.58V |#######                                          |
             |
 0 0.60V |#######                                          |
6V |#######                                          |
 0 0.59V |#######                                          |
 0.56V |#######                                          |
 0 0.56V |#######                                          |
 0.57V |#######                                          |
 0 0.58V |#######                                          |
         |
 0 0.56V |#######                                          |
#######                                          |
 0 0.56V |#######                                          |
 0.56V |#######                                          |
 0 0.57V |#######                                          |
 0.56V |#######                                          |
 0 0.57V |#######                                          |
     |
 0 0.56V |#######                                          |
###                                          |
 0 0.57V |#######                                          |
 0.60V |#######                                          |
 0 0.60V |#######                                          |
 0.53V |######                                           |
 0 0.55V |#######                                          |
 |
 0 0.57V |#######                                          |
                                         |
 0 0.55V |#######                                          |
 0.58V |#######                                          |
 0 0.53V |######                                           |
 0.55V |#######                                          |
 0 0.57V |#######                                          |

 0 0.50V |######                                           |
                                     |
 0 0.73V |#########                                        |
 0.41V |####                                             |  
 0.0.41V |####                                             |
 0.66V |########                                         |
 0 0.00V |#################################################|

 0 3.29V |#################################################|
###############                  |
 0 0.00V |#################################################|
 0.89V |############                                     |##
 0 0.00V |#################################################|
 0.00V |#################################################|
 0 2.46V |####################################             |

 0 0.00V |#################################################|
#############################|
 0 3.29V |#################################################|
 3.29V |#################################################|##
 0 0.10V |                                                 |
 3.29V |#################################################|
 0 3.29V |#################################################|

 0 0.00V |#################################################|
#########################|
 0 1.51V |#####################                            |
 3.29V |#################################################|  
 0 0.02V |#################################################|
 0.05V |                                                  |
 0.93V |############                                     |
 0 3.29V |#################################################|
 0.00V |#################################################|
 0 0.00V |#################################################|
 |
 0 3.29V |#################################################|
#########################################|
 0 1.92V |############################                     |
 3.29V |#################################################|
 0 1.84V |##########################                       |
 1.26V |##################                               |
 0 1.46V |#####################                            |

 0 0.89V |############                                     |
                                     |
 0 0.75V |##########                                       |
 0.81V |###########                                      |  
 0.0.52V |######                                           |
 0.60V |#######                                          |
 0 2.55V |######################################           |

 0 3.01V |#############################################    |
###############################  |
 0 3.29V |#################################################|
 3.29V |#################################################|##
 0 2.99V |############################################     |
 3.29V |#################################################|
 0 3.29V |#################################################|

 0 0.00V |#################################################|
#############################|
 0 3.29V |#################################################|
 3.29V |#################################################|##
 0 3.29V |#################################################|
 3.29V |#################################################|
 0 3.29V |#################################################|

 0 3.29V |#################################################|
#########################|
 0 3.29V |#################################################|
 3.21V |################################################ |##
 0 3.29V |#################################################|
 3.29V |#################################################|
 0 3.29V |#################################################|

 0 2.79V |#########################################        |
                     |
 0 1.41V |####################                             |
 1.05V |##############                                   |  
 0 0.80V |###########                                      |
 0.70V |#########                                        |
 0 0.64V |########                                         |
 0 0.63V |########                                         |
 0 0.57V |#######                                          |
                 |
 0 0.60V |#######                                          |
 0.51V |######                                           |
 0 0.55V |#######                                          |
 0.54V |######                                           |
 0 0.54V |######                                           |
 0.61V |########                                         |
 0 0.62V |########                                         |
             |
 0 0.54V |######                                           |
0V |#######                                          |
 0 0.56V |#######                                          |
 0.54V |######                                           |
 0 0.55V |#######                                          |
 0.60V |#######                                          |
 0 0.62V |########                                         |
         |
 0 0.62V |########                                         |
######                                           |
 0 0.59V |#######                                          |
 0.62V |########                                         |
 0 0.63V |########                                         |
 0.50V |######                                           |
 0 0.53V |######                                           |
     |
 0 0.60V |#######                                          |
##                                           |
 0 0.53V |######                                           |
 0.54V |######                                           |
 0 0.54V |######                                           |
 0.59V |#######                                          |
 0 0.57V |#######                                          |
 |
 0 0.59V |#######                                          |
                                         |
 0 0.61V |########                                         |
 0.62V |########                                         |
 0 0.54V |######                                           |
 0.54V |######                                           |
 0 0.57V |#######                                          |

I am receiving the output in few lines per reading, one reading per second to two seconds. Some lines don't start from their beginning.
The situation is identical on both Linux and Windows on my "external" PC (not laptop). And on my laptop readings are worse - less frequent and more cropped/choppy. When I touch pins with a finger I always get maximum readings (maybe gain is turned on, but shouldn't be on default).
I tried different clock settings but that didn't change anything:
/*adc.h */
#define ADC_CLK  2400000  /* default set to 2.4Mhz */

/* adc.c */
void ADCInit( uint32_t ADC_Clk )
{
...
LPC_ADC->CR = ((SystemCoreClock/LPC_SYSCON->SYSAHBCLKDIV)/[color=#00f]ADC_Clk[/color]-1)<<8;
...
}


I use debug mode because I am new in electronics. I know few things in theory and have very little practice.

Summary:
1. Why readings are soooooo slow (infrequent)? Is it because of the debug mode?
2. Why readings are cropped?

Can You help?
Thank You
Jakub
Labels (1)
0 Kudos
3 Replies

358 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Jakub16 on Mon Nov 10 10:29:27 MST 2014
In debug_printf.c:
int _debug_putchar(char c)
{
uint8_t buffer_has_room = 1;

if((debug_buf_write_index+1)%DEBUG_OUTPUT_BUFFER_SIZE  == debug_buf_read_index
#if defined(FLUSH_ON_NL)
               || [color=#900]c == '\n'[/color])
#else
        )
#endif
{
            buffer_has_room = _debug_printf_flush();
}


So I have commented out this line in debug_printf.h
//#define FLUSH_ON_NL


...and the results are prettier, but still readings appear too rarely:

m = 0 0 2.81V |##########################################       |
m = 1 0 2.48V |####################################             |
m = 2 0 1.99V |#############################                    |
m = 3 0 1.44V |####################                            |
m = 4 0 1.32V |###################                              |
m = 5 0 0.90V |############                                     |
m =  0 0.95V |#############                                    |
m = 7 0 1.00V |#############                                    |
m = 8 0 0.72V |#########                                  |
m = 9 0 0.57V |#######                                          |
m = 10 0 0.68V |#########                                      |
m = 11 0 0.71V |#########                                        |
m = 12 0 0.51V |######                                           |
m = 13 0 0.60V |#                                       |
m = 14 0 0.63V |########                                         |
m = 15 0 0.68V |#########                                      |

0 Kudos

358 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Jakub16 on Wed Jan 29 14:41:37 MST 2014
Hi,
It's very hard for me to get down to my device, but some time ago I was given a clue here (youtube /watch?v=ktq5AbGSXKc), quote:
"I used NXP's pre-compiled DSP libraries for this which are not compatible with the Cortex-M0 family, so I can't say I've tried something similar with the LPC1114. Seeing as the LPC1114 doesn't have a USB controller I would imagine you are using UART. I know a few of the FTDI serial to USB converters don't do well with high speed streaming data. Try creating a counter that generates data at the same rate as your ADC. Otherwise check your ADC triggering, transfer routines, and setup registers."
0 Kudos

358 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giamby3000 on Wed Nov 13 01:47:00 MST 2013
Hi I have the same problem withLPCXpresso board LPC1114 302 with the example provided in LPCXpresso sample folder.
ideas?

Thanks
0 Kudos