d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Iso Help Configuring A Microcontroller > Using Codevision Avr
Add Reply New Topic New Poll
Member
Posts: 1,274
Joined: Oct 31 2005
Gold: 140.00
Feb 27 2014 09:16am
I know that CV AVR is a C compiler, but this is not your regular C programming so I wasn't sure where to post this.

I am learning how to program ATXmega microcontrollers and I'm having difficulties.

I have a board with the following: microcontroller, accelerator sensor, analog-digital converter, logic level converter and other stuff (I have the schematic).
First: I need to configure the microcontroller so it can communicate with everything on the board.
Second: I need to programming the microcontroller to pull data from the accelerator sensor and output it using the ADC.

The programming part I think I can manage, but I got no clue on how to configure the microcontroller.


If there is anyone that could help, I can give you more details.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 27 2014 01:43pm
First off download atmel visual studio, second read the data sheet of your micro controller. You won't get anywhere with creating/programming your own hardware if you can't find the datasheets of what you're working with. All the required info is in there.

As for setting up your pins, you have to figure out what ports you want to use. Here's a few examples.

Code

DDRB = 0xFF; //Set all pins on PORTB to output

DDRD &= ~(1 << PD2); //Set PD2 (Pin 2 portD) to input. (1 << PD2) Creates 000000100 and the ~ operator reverses it, 111111011, Then it AND's them to the current pin configuration on port D.

if(PIND & (1 << PD2)) //Checks to see if a specific pin is set. This generates the binary 000000100 and uses AND to compare.

PORTB |= (1 << PB2); //Pulls PB2 pin high
PORTB &= ~(1 << PB2); //Pulls PB2 Low.
Member
Posts: 1,274
Joined: Oct 31 2005
Gold: 140.00
Feb 27 2014 10:44pm
Thank you for bothering to write.

I have the XMega A manual for the microcontroller and a schematic of the board.
CodeVision has a Wizard that writes a huge part of the code for me, all I have to do is configure the microcontroller using that wizard. (at least that's the step that I am having difficulties with)

Here is the microcontroller part of the schematic:


Here is an image on how the wizard looks like:



I'm having difficulties interpreting the schematic.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 27 2014 11:25pm
I am not sure, this is going to be harder then interpreting the schematic. You will need to learn how to communicate with the other hardware which will expect a specific high low sequence to write and read from its registers. It is more than hooking up the wires and the pins via a wizard and hoping it works. See if your other hardware comes with documentation or programming SDK that you can use.
Member
Posts: 1,274
Joined: Oct 31 2005
Gold: 140.00
Feb 28 2014 12:53am
I have the driver files (source and header) of the acceleration sensor and the ADC
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 28 2014 02:47pm
Quote (gogutzu @ Feb 28 2014 02:53am)
I have the driver files (source and header) of the acceleration sensor and the ADC


From there you are going to have to analyses for find documentation to find out how to use them. Setting up the pins is one thing (which I assume is what your wizard is trying to do), but figuring out how to send data to the other hardware in a way they want it is the hard part. For example a Nintendo 64 controller works on a bidirectional data line with a protocol of high/low toggles of a rate of 2-3usec. Since I don't know, and haven't used, a acceleration sensor I don't really know how to interface with them.

This post was edited by AbDuCt on Feb 28 2014 02:48pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll