ZX328n device strange behavior

This forum is for posts that might be considered off-topic but that may be useful or interesting to members. Examples include posts about electronics or programming in general, other microcontrollers or interesting devices, useful websites, etc.
Post Reply
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

ZX328n device strange behavior

Post by rich »

I set up a ZX328n, 28-pin ATmega328p, on a bread board and it loaded and ran the sample "Hello World" program first time.

The power comes from a Basic Serial USB module from Sparkfun. I added a power switch and it did not shut it off.
When i removed 5 volts, by taking out the jumper wire, it still worked.

After probing i found that the chip had 3.5 volts on it being sourced from pin-20 of the device, AVCC which was connected to the VCC pin of the chip.

The chip was making its own power and working fine at 14... MHz. The Hello World was sending its message to the debug window of the IDE and all was looking good.

After disconnecting most every pin i found that the serial input to the device, which was not being used while the program ran, was leaking current into the device causing the device to output 3.5 volts and work just fine.

I disconnect the serial input, pin-2, and now the devices powers down when +5 volts is switched off.

Anyone have such and experience before?

Richard
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: ZX328n device strange behavior

Post by dkinzer »

rich wrote:i found that the serial input to the device, [...] was leaking current into the device [...]
This is a well known phenomenon on devices that have protection diodes on their inputs.

You can better understand what is happening by studying the equivalent circuit for an I/O pin, reproduced in the attached image excerpted from the mega328P datasheet (but common to most, if not all, AVR devices). The upper protection diode has its cathode connected to the Vcc bus of the device thus allowing a signal applied to the I/O pin to power the chip through the protection diode.

The other fact that helps explain what you observed is that RS-232 signals idle in the "marking" or "logic high" state. For a TTL-level RS-232 signal the idle state would be 4 to 5 volts or so so the chip would be powered one diode drop below that level.
Attachments
IO_pin.jpg
IO_pin.jpg (19.65 KiB) Viewed 3210 times
- Don Kinzer
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Post by rich »

Thanks for the incite.

I will think of a better power down method.

cheers,
Richard
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Post by rich »

Now i have gotten the baud rates of the target different than the IDE.

I was wondering if i could get the debug.print to run at 115200 so i set the Execution Option in the Serial Port option dialog to 115200.

I compiled, built, and go and then the Hello World comes out mush. So i changed the number back to 9600, the original value, compiled, built, and go and still the baud rate are mismatched.

The code download and verifies each time no matter what the Execution Option baud rate is.

How do i get both the IDE and target to talk the same baud rate?

Thanks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

rich wrote:How do i get both the IDE and target to talk the same baud rate?
The default console speed on the ZX devices is 19,200 baud so if you change the Execution Baud Rate to 19,200 it should work fine.

If you want to use a different console speed, you have to change it in the application and make a matching change in the IDE. The directive for changing the console speed in the application is Option ConsoleSpeed as described on the manual page below.

http://www.zbasic.net/doc/ZBasicRef.php?page=26

If you want the console speed to be 115200 you would use

Code: Select all

Option ConsoleSpeed 115200
near the beginning of the main module of your application and make the matching change in the IDE. The change in console speed of the application does not take effect until you download the application to the ZX device. In contrast, the change to the IDE execution speed takes effect immediately.

Downloading the application to the device is done at a pre-determined speed that is unaffected by any of the changes described above. That's why downloading worked even though the application console output was garbled.
- Don Kinzer
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Post by rich »

Thank you much.
I see my mistakes now that you helped me.

cheers,
Richard
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Post by rich »

Thank, it worked like a champ.

cheers,
Richard
Post Reply