- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I try to read counter register. I'm sure thatTimer_24 works.
in main loop
Timer24_ReadTimerSaveCV(&readTimer);
LCD_Position(1,1);
LCD_PrHexInt(readTimer);
but LCD shows me only 0000, I couldyn't find why.
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found out that Capture must be set to low, but I don't know why
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The f() you use does not have any parameters, but it returns what
you want.
Timer16_wReadTimerSaveCV
- Description:
- Reads the current Timer16 Count register value, while preserving the Compare registers. This performs a software-solicited, hardware-synchronous counter capture operation. This function should only be used if the contents of the Compare register must be preserved. If the Compare register contents do not need to be preserved, then using the wReadTimer() function is preferred. Note that this API routine used to be called wReadCounter.
- C Prototype:
-
WORD Timer16_wReadTimerSaveCV(void);
- Assembly:
-
lcall Timer16_wReadTimerSaveCV
mov [wCount], X ; MSB returned in X
mov [wCount+1], A ; LSB returned in A
- Parameters:
- None
- Return Value:
- wCount: Count register contents. MSB is passed in the X register and LSB is passed in the Accumulator.
So you should have something like -
readTimer = Timer24_ReadTimerSaveCV( );
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it's right for 16bit timers, but for 24bits timers datasheet says
Timer24_ReadTimerSaveCV
- Description:
- Reads the current Timer24 Count register value, while preserving the Compare registers. This performs a software-solicited, hardware-synchronous counter capture operation. This function should only be used if the contents of the Compare register must be preserved. If the Compare register contents do not need to be preserved, then using the ReadTimer() function is preferred. Note that this API routine used to be called ReadCounter.
- C Prototype:
-
void Timer24_ReadTimerSaveCV(DWORD * pdwCount);
- Assembly:
-
mov A,[pdwCount]
mov X,[pdwCount+1]
lcall _Timer24_ReadTimerSaveCV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a note in datasheet that alludes to an issue with Capture,
but is not "complete" in its warning, or so I think -
- Capture
-
This parameter is selected from one of the available sources. A rising edge on this input causes the Count register to be transferred to the Compare register. The software capture mechanism will not operate correctly if this parameter is set to a value of one or is held high externally.
Regards, Dana.