Enabling and Disabling Counter in Firmware.

Question: I am looking for at way to enable and disable the counter. I can use the User Module's Enable Parameter to enable and disable the counter (by setting it to High or Low). How do I do this in firmware?

 

Answer:

The counter is controlled by both the Hardware Enable Input controlled by the DxBxxIN register and the Enable bit in the DxBxxCR0 register. The counter will operate only when the Hardware Enable input is high and the Enable bit in the CR0 register is high. The simplest way to enable and disable the counter is to set the Enable Input of the counter to High in the device editor and use the Counter_Start and Counter_Stop functions from the Counter's API. Alternately, the counter may also be started and stopped by setting the Enable signal to High and Low respectively by writing to the DxBxxIN register (The Enable bit in the CR0 should be set). Same is the case with other basic digital User Modules.