On 15.08.2016 21:42, Maarten Brock wrote:
>> On 15.08.2016 20:54, Maarten Brock wrote:
>>>> On 15.08.2016 20:01, Philipp Klaus Krause wrote:
>>>>> Hello,
>>>>>
>>>>> I wrote my first little mcs51 program today, for the Cypress FX2LP.
>>>>> But
>>>>> I encountered a problem: Timer 1 runs too fast. When I set up Timer 0
>>>>> and Timer 1 the same, Timer 1 runs about 4 times faster.
>>>>>
>>>>> I first noticed the problem when trying to do a software UART, which
>>>>> worked with Tiemr 1, but not with Timer 2.
>>>>>
>>>>> I have attached programs for a 2-bit counter on the LEDs of my board a
>>>>> bits 0 and 1 of port A. With Timer 1, the counter increments once per
>>>>> second.
>>>>
>>>> The previous two paragraphs were meant to be:
>>>>
>>>> I first noticed the problem when trying to do a software UART, which
>>>> worked with Tiemer 0, but not with Timer 1.
>>>>
>>>> I have attached programs for a 2-bit counter on the LEDs of my board a
>>>> bits 0 and 1 of port A. With Timer 0, the counter increments once per
>>>> second.
>>>>
>>>>> I compile my programs using
>>>>> sdcc -mmcs51 test2.c
>>>>> and put them onto the FX2LP using
>>>>> cycfx2prog prg:test2.ihx run
>>>>>
>>>>> Philipp
>>>
>>> Hello Philipp,
>>>
>>> You did not set CKCON which selects the prescaler clk/4 or clk/12. T0M
>>> and T1M should be 0 after reset, but the loader may have left them
>>> differently.
>>>
>>> Maarten
>>
>> I didn't set it. But by setting it I can make the timer run even faster.
>>
>> Philipp
> 
> Then maybe you didn't clear TMOD.2 (C/T0) when using timer 0? Then you
> would be counting whatever happens on T0.
> 
> Maarten

The problem was indeed a wrong TMOD setting. I was running in 13-Bit
timer mode for timer 1, while using 16-but timer mode for timer 0.

Philipp



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to