Guest AtomSoft

First Projects

Recommended Posts

Guest AtomSoft

Hey i ordered my papilio one from CuteDigi hope you dont mind...

I did my first projects:

http://www.electro-tech-online.com/microcontrollers/120525-fpga-12.html#post996655

and second:

http://www.electro-tech-online.com/microcontrollers/120525-fpga-12.html#post996698

i also implemented the AVR soft core with a  custom peripheral which has 4 registers..

3 control (RATE) registers

1 Status register

Internally there is a 24 bit rate register which pulls in data like:

            rate_reg(23 downto 16) <= control_reg;
            rate_reg(15 downto <= control2_reg;
            rate_reg(7 downto 0) <= control3_reg;

I wanted to know can i simply create a 24 bit register to write directly to ?

Share this post


Link to post
Share on other sites

The projects look good and I don't mind you ordering from CuteDigi at all. :)

I wanted to know can i simply create a 24 bit register to write directly to ?

Can you elaborate more on what you want do to do? The I/O bus is 8 bits wide from what I remember so you can implement a 24 bit register but need multiple reads or writes to access it. I'm not sure if that is what you were asking though.

Jack.

Share this post


Link to post
Share on other sites
Guest AtomSoft

Thanks, thats what I have done. I setup 3 8 bit registers and then just merge them into one 24bit ... which is fine anyway...

Ok i have a question, I have like no experience with Arduino type code so wanted to know.. Can i implement a register and be able to set a bit at a time without having to set the entire register? Like in PIC micros i can:

LATA = 0x01; // This sets the entire port output latches to 0000 0001

What i want to do is more like:

LATAbits.LATA0 = 1; //This just sets BIT 0 to a 1

How would i do this in Arduino ? Can i give the bits nice names ?

Basically i am going to try and make a LCD Peripheral for the AVR softcore and wanted to make a control register where each bit has a specific purpose like

CONTROL REG -

BIT 7 = LCD CS Control

BIT 6 = LCD RS Control

BIT 5 = LCD WR Control

BIT 4 = LCD RD Control

BIT 3 = LCD RST Control

BIT 2 = LCD BACKLIGHT Control

BIT 1 = ....To come later

BIT 0 = ....To come later

How can i make it so i can simply use the arduino style...

ControlReg.CS = 1; //Something like this...

Share this post


Link to post
Share on other sites

Hi,

See the AVR bit manipulation instructions for this (SBI/CBI). For IO you can also toggle individual bits.

From  ATMEGA48/168/328 datasheet:

13.2.2 Toggling the Pin

Writing a logic one to PINxn toggles the value of PORTxn, independent on the value of DDRxn.

Note that the SBI instruction can be used to toggle one single bit in a port.

Álvaro

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now