Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] accessing bits (e.g. of ports)

2005-01-31 by ethan@bufbotics.org

Mike Perks said:
>
> Const Motor_Enable_Pin as Byte = 22
> Const Turn_Motor_On as Byte = bxOutputHigh
> Const Turn_Motor_Off as Byte = bxOutputLow
> ...
> Sub Main()
> ...
>     call PutPin(Motor_Enable_Pin, Turn_Motor_On)
> ...
> End Sub
>

Mike,

Thanks for the info.  The code you lay out is definitely more readable, I
like it.

Does anybody know how to do this in avr-gcc?

Also, the more I think about it, I might just start writing some more
specific routines (either functions or macros for simpler actions) for
doing all my I/O from AVR.

I'm a Java coder at heart, and we LOVE to completely hide all
implementation detail behind pretty interfaces.  So I could "pretend" I
have interfaces if I do all my I/O via some special macros/functions I
write.

The real reason I like this approach is because, when I'm first
prototyping, perhaps I use simple functionality like when I want to turn
off an LED, I just shut it off.  But when I go to my final "production"
version of the system, maybe I want the LED-off functionality to gently
dim the LED and then shut it off.  If I used a modular code design early
on in the process (when it seems stupid to be modular since the module is
one line long), then twould become nice and easy to add in my fun changes.


Ethan
www.bufbotics.org

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.