ATN woes

Discussion specific to the 24-pin ZX microcontrollers, e.g. ZX-24r, ZX-24s and ZX-24t.
Post Reply
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

ATN woes

Post by GTBecker »

As Emily Latilla said, never mind.

I needed to update the VM (an Emergency Update on one of the machines) on another project socket. Now, while digging through the docs to convert BX-24 code to ZBasic, I find I didn't read the documentation far enough. The app uses three PWMs. Bummer.

Back to the BX-24p.


Tom
Tom
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Re: ATN woes

Post by spamiam »

GTBecker wrote:The app uses three PWMs. Bummer. Back to the BX-24p.


Tom
Your application is using 3 PWM channels on the BX-24P? It has been a while since I used the BX, but I was not aware that it had more hardware PWM capabilities than the ZX.

The ATMega8535 on the BX24P has one 16 bit timer and two 8 bit timers. So, It does not have more basic hardware PWM support than the ATMega32 or 644.

It has been a year since I messed with PWM on the ZX, but I think it is possible to get 2 channels of PWM on the 16-bit timer, and you can still access one of the 8-bit timers for another 2 channels.

Off the top of my head, I would have thought that you could get 4 PWM channels on the ZX if you had limited needs for other timer-based operations.

My impression was that the ZX platform was at least the equal of the BX in PWM support. I guess I am wrong!

-Tony
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Re: ATN woes

Post by GTBecker »

> ... Your application is using 3 PWM channels on the BX-24P? It has been a while since I used the BX, but I was not aware that it had more hardware PWM capabilities than the ZX.

Yes, two motors and an IR source. I, too, have not read of any BX-24 capability that the ZX processors lack, but here it is, I guess. It appears that Timer2 is used for other internals in the ZX-24 processors.

Don?


Tom
Tom
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

The ZX-24 has 3 PWM channels as well. You can use the two PWM channels on Timer 1 and you can use Timer 2 as a 8-bit PWM if you don't use logical serial ports.

This page explains the resource allocations of the chip: http://www.zbasic.net/doc/ZBasicSysLib/ ... Lib17.html
Mike Perks
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

ATN woes

Post by GTBecker »

> ... you can use Timer 2 as a 8-bit PWM if you don't use logical
serial ports.

Thanks, Mike. Then, unless I missed it, the documentation needs some
work, or OpenPWM(), ClosePWM() and PWM() should accept a third ZX-24 PWM
channel. And there's this: Error: reference to undefined identifier
"Register.TCCR2". How can I load that control register?


Tom
Tom
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Re: ATN woes

Post by mikep »

GTBecker wrote:> ... you can use Timer 2 as a 8-bit PWM if you don't use logical
serial ports.

Thanks, Mike. Then, unless I missed it, the documentation needs some
work, or OpenPWM(), ClosePWM() and PWM() should accept a third ZX-24 PWM
channel. And there's this: Error: reference to undefined identifier
"Register.TCCR2". How can I load that control register?


Tom
I think Don elected not to provide the third PWM port because by default Timer2 is assigned to logical COM ports.

The error you are getting is because you have the wrong CPU setting; either in your project file, the source code or the device pulldown in the IDE. The easiest fix is to add the following line to your source code:

Code: Select all

Option TargetCPU ZX24
Mike Perks
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

ATN woes

Post by GTBecker »

> ... The error you are getting is because you have the wrong CPU
setting; either in your project file, the source code or the device
pulldown in the IDE. The easiest fix is to add the following line to
your source code:
*Code:*
Option TargetCPU ZX24
You're right. Actually, I have the correct processor Option:

Option TargetDevice ZX24a

which still does not like TCCR2. ZX24, the wrong machine, allows
TCCR2. That seems like a bug.

Thanks, Mike.


Tom
Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

Further, the IDE will not download to the wrong device. So, if I lie to the compiler, I can't load the machine. If I don't lie to the compiler, I can't compile the code. Is there an override to force the code to the wrong machine?
Tom
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Re: ATN woes

Post by mikep »

GTBecker wrote: Option TargetDevice ZX24a

which still does not like TCCR2. ZX24, the wrong machine, allows
TCCR2. That seems like a bug.
On a Mega644 there are two control registers for Timer2 called TCCR2A and TCCR2B. This is needed because they added a second timer output (OC2B on D.6) which needs additional control bits. There is also a second output compare register called OCR2B. The compiler is correctly complaining that it doesn't understand register TCCR2 on the ZX "a" devices.

Here is the ATMega644 reference http://oakmicros.com/content/downloads/ ... atasheets/ . Yeah I know it's my website but all the manuals are in one nice place and I need the hits ;)
Mike Perks
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

ATN woes

Post by GTBecker »

> ... Mega644 there are two control registers for Timer2 called TCCR2A
and TCCR2B.

Ah, hah! There it is! I've been blindly staring at the 32 docs.
Sorry; thanks for the guidance.

Ok, then! Never mind.


Tom
Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

[Much later:] I found a root problem. I use a processor pin to control some external logic that switches ATN and RX between tether and wireless. All processor I/O floats during reset, including during the ATN-test period, which essentially disconnected those lines from the processor until the pin is initialized when my code started.

The solution is a pulldown on the pin, or I need to invert that pin logic if it reliably floats high, which seems the case.
Tom
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: ATN woes

Post by dkinzer »

mikep wrote:I think Don elected not to provide the third PWM port because by default Timer2 is assigned to logical COM ports.
The primary reason for not including the software UART timer (e.g. Timer2) is because it only has 8-bit resolution and the calculations required for it are significantly different than for 16-bit timers. If the additional PWM channel is needed, the code in the PWM application note that Tony wrote can be used (possibly with some modifications).
- Don Kinzer
Post Reply