| Author |
Message |
GTBecker
Joined: 18 Jan 2006
Location: Cape Coral
|
|
Posted: 05 September 2007, 1:17 AM Post subject: ATN woes |
|
|
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 |
|
| Back to top |
|
 |
spamiam
Joined: 13 Nov 2005
|
|
Posted: 05 September 2007, 16:33 PM Post subject: Re: ATN woes |
|
|
| 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 |
|
| Back to top |
|
 |
GTBecker
Joined: 18 Jan 2006
Location: Cape Coral
|
|
Posted: 05 September 2007, 16:38 PM Post subject: Re: ATN woes |
|
|
> ... 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 |
|
| Back to top |
|
 |
mikep
Joined: 24 Sep 2005
Location: Austin, TX
|
|
Posted: 05 September 2007, 17:23 PM Post subject: |
|
|
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/ZBasicSysLib17.html |
|
| Back to top |
|
 |
GTBecker
Joined: 18 Jan 2006
Location: Cape Coral
|
|
Posted: 05 September 2007, 17:59 PM Post subject: ATN woes |
|
|
> ... 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 |
|
| Back to top |
|
 |
mikep
Joined: 24 Sep 2005
Location: Austin, TX
|
|
Posted: 06 September 2007, 0:33 AM Post subject: Re: ATN woes |
|
|
| 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: | | Option TargetCPU ZX24 |
|
|
| Back to top |
|
 |
GTBecker
Joined: 18 Jan 2006
Location: Cape Coral
|
|
Posted: 06 September 2007, 0:50 AM Post subject: ATN woes |
|
|
> ... 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:
| Quote: | *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 |
|
| Back to top |
|
 |
GTBecker
Joined: 18 Jan 2006
Location: Cape Coral
|
|
Posted: 06 September 2007, 1:09 AM Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
mikep
Joined: 24 Sep 2005
Location: Austin, TX
|
|
Posted: 06 September 2007, 1:44 AM Post subject: Re: ATN woes |
|
|
| 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/View-category/Other-Datasheets/ . Yeah I know it's my website but all the manuals are in one nice place and I need the hits  |
|
| Back to top |
|
 |
GTBecker
Joined: 18 Jan 2006
Location: Cape Coral
|
|
Posted: 06 September 2007, 2:04 AM Post subject: ATN woes |
|
|
> ... 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 |
|
| Back to top |
|
 |
GTBecker
Joined: 18 Jan 2006
Location: Cape Coral
|
|
Posted: 09 September 2007, 16:18 PM Post subject: |
|
|
[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. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 10 September 2007, 3:46 AM Post subject: Re: ATN woes |
|
|
| 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). |
|
| Back to top |
|
 |
|