Did you already try to just write static data to the LCD? That way you can rule out problems with regards to that. If you succeed with that, try as next step to show data you have sampled.
I cannot see the places where you set the "dataready" variables, probably you set it in the generated .c-files.
Since this can get lost under some circumstances I would suggest to use a different way using an own interrupt module and
CY_ISR_PROTO(), CY_ISR() and isr_StartEx() as described in "System Reference Guide" under Creator Help.
There is an API for your ADC that will check or wait for a conversion done, first try could be to use this instead of an interrupt.
The conversion of an int16 to a string is best done with sprintf() but you may use the number-conversion routines of the LCD-module, look at the APIs in datasheet. Remember you do not have got an OS in the world of embedded processors, so you'll have to do everything yourself. So your function gcvt() may not work.
If there is nothing to see on your LCD try to write a "Hello World" and wait for a second...
Somne thoughts -
1) You have two arrays, each int16, sized 19200. By my calculations
thats 76800 bytes, the part only has 64 KB. That leaves no room for stack
or any other variables, your own or the API's.
2) The arrays are declared as int16 in 1) above, but you are stuffing them
with a float from ADC_SAR_1_CountsTo_Volts(resultn); The arrays should
be declared as float.
3) The LCD has no applicable number conversion routines for what you are
trying to do. Bob's recommendation to use sprintf() makes most sense.
Attached help with formatting for sprintf()/printf().
Thanks for Bob and danaaknight's help.First,i want to convert the float to the string,but the sprintf() may not have this function.And,i modified my project,the gcvt() can work well.But,i wonder why ADC_Setoffset() can not influent on the result of ADC_CountsTo_Volts().There are negative numbers should be showed on the display in my ideal result.So,can you help me?PS:Bob is right,I set the ADC own interrupts in ADC_SAR_1_INT.c and ADC_SAR_2_INT.c.
Your interrupt handling dissapeared again, so dataready didn't become ready . Now it's using the safe way.
static array in main() gets initialized to zero when main() starts, that takes a lot of time, so I declared them as global vars.
That were the only changes I made. Program tested and is running.
I looked at code and here are some thoughts -
1) Your reference should be Vdd/2, and range set to 0.0 ± Vdda/2 (Differential) –Input ± Vdda/2
You should not need to use the offset function then.
2) You did not set the flags in the IRQ, dataready1 and dataready2 when ISR
3) You are converting at a rate of 100 KSPS, then trying to write LCD at that rate.
LCD has its own controller, and at this rate you are over writing the LCD rate wise.
It will never display every sample taken. Seems to me you should take a set of samples
(5000) then step thru the sample array showing on LCD at some very slow rate ?
4) You di not enable global interrupts. Right after you enter main() issue a CyGlobalIntEnable;
5) In ISR you set a flag, then in main() try to process loading array with sample. Problem I
see is that at 100 KSPS guarenteeing main() stores the sample in time problematic. I would
think about doing that in the ISR, which then requires you inc the i pointer for the array.
In general you might want to consider a DMA approach to memory to get the arrays filled.
yeah,the interrupt functions in the files expect main .c always disappear after rebuilding the project.I adopt the your recommendations.It work well.Thanks Bob.And i also learn a lot from your coding style.Thanks also to danadak,your suggests are also useful.