- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm working on an assignment for my studies, I'm making a system that measures the voltages of two incoming channels with the SAR ADC component. I understand that this component resides within the Programmable Analog block of the PSoC 4. Another part of the application writes the measured voltage of the first channel to a 7-segment display, which is located on an extension board. The display has four digits, only one digit is written to the display at a time, but with a high enough refresh rate the user won't notice any flickering.
The frequency I chose for writing a digit to the display is 200Hz. I have implemented this with a Timer Counter, where the clock frequency is 100kHz and when the counter hits the 500, an interrupt is generated (writing the digit).
This was fine when (at first) I only had 1 Analog channel to measure. But with 2 analog channels the PSoC appeared to have trouble reaching the 200Hz (this I assume as I clearly saw flickering). I think I have solved the problem by reconfiguring the SAR ADC with a higher sample frequency (now at 12Mhz) and a lower averaged result (from 256 to 64 samples), which leads to a result within 117us per channel. I can't see the 7-segment display flicker any more:)
But wait, why would the ADC influence my 7-seg display in the first place? This I don't understand, I was hoping that someone can shed some light here. I thought the ADC is implemented in the (programmable) 'hardware', so it won't take up any resources from the ARM microcontroller, right? Also the Timer Counter resides in 'hardware' yes? (in the programmable digital block?)
If more info (or the project files?) is needed for giving an answer, let me know!
Thanks much,
Caspar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would prefer having a look at all your settings and your code, can you post it here? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is an approach that can be used to eliminate flicker in a display.
Basically create a char array the size of the display. Say its 1 x 16, so
array would be disray[ 17 ], one more to hold the NULL character
that terminates a string.
Then when you want to write to the display check to see if the char you
want to write has changed from whats in the buffer. If it has replace buffer
char and write out to the display. If not do nothing. This will eliminate a lot
of "artifacts" in displayed data due to excessive display write, write only whats
changed, digit for digit.
I used this on a LCD display, quite effective. On a LED digit display should
also help.
The approach requires no HW, you can write the display as fast or slow as you
want.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looking at project -
1) Upgrade to Creator 3.1 SPI, bug fixes and improvments are always fixed in each release.
2) Your clock for SAR is set to 12 Mhz, 9 Mhz is limit per wizard.
3) In ISRs -
a. minimize code in ISRs, wherever possible just set a flag, exit, process in
main(). That will eliminate a lot of stack push, and consequent loss of MIPS.
b. All globals in ISR should be declared as volatile.
http://www.barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword Volatile
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you try to give the Refresh_Update_ISR a higher interrupt priority? It might just be that the other ISRs take too much time.
Can you use the LATCH signal to measure the actual display refresh speed? Is it really too low? If its 200Hz, Dana solution might be right and the flicker comes because your display refresh overlaps with the display update (from the ADC) - if they are near enough you might see flicker. Try to update the display values (bot the refresh) just 10 times per second or so, and average the values in the meantime.
Btw: the I tried to build your project, and it won't with a 12MHz ADC clock.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Dana,
I'll try your suggestions, although I forgot to mention that the four digits on the 7-segments display are controlled by two 8-bit shift registers. The solution where digits are only updated when needed won't work as the 7 segments of each digit are interconnected with the same segments on the other digits.
Caspar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What you can do too is to use a SPI master to drive the shift register. Set it to 8 bit and send out two bytes. The SPI component can control the LATCH output via its slave select line. That can free up computing resources.
(And on a PSoC5LP or the upcoming PSoC4M I would even suggest using the DMA to make it fully automatic, but the PSOC4 hasn't got one)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I like the idea of using the SPI master component for writing data to the shift register, I'll give that a try. But I also saw a 'Shift Register' component that has a ShiftRegister_WriteRegValue() routine, could that be used also?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Btw, @hli you said "wont' build with a 12Mhz clock": could that be a difference in your/my platform? I have the CY8C4245SXI-483
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just opened your project (with Creator 3.1SP1, so some components where updated). I made no changes, just tried to build.
Yes, you can use the shift register too (in the end its a more simple version of SPI). But it needs a UDB, the SPI is available as fixed function block. And the SPI can handle the LATCH signal for you too.