AtMega48P BLDC control

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I'm using, or trying to use, a AtMega48P for controlling a sensorless Brushless DC Motor. However, I encounter difficulties with compiling the C-code that I found on the Atmel website.
When compiling, it gives me a few errors. The software I use for this is IAR Workbench.

All pins on port B and port D are undefined and the keyword "__regvar" is unavaible with the current port settings.

As for the undefined pins, my guess is that there is a problem with the library, although I added the library that was included in the AVR444 package that I found on the Atmel website.

This is for a school project, with the deadline approaching next week. Any help, ANY help, would be deeply appreciated!

Kind regards,
Ragnor

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you check readme.html?

Quote:
3. Enable bit definitions in I/O include files

/Martin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can do it as follow:
#define PB0on PORTB|=0x01
#define PB0off PORTB&=0xfe
...
...

Nobody can go back and start a new beginning, but anyone can start today and make a new ending.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

cheng_bei wrote:
You can do it as follow:
#define PB0on PORTB|=0x01
#define PB0off PORTB&=0xfe
...
...

Is that in the C-code itself, or in the .h file?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
You can do it as follow:
#define PB0on PORTB|=0x01
#define PB0off PORTB&=0xfe

This solution will not work without a lot of modifications to AVR444.

/Martin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mtaschl wrote:
Did you check readme.html?
Quote:
3. Enable bit definitions in I/O include files

Yes, I did read the readme. I enabled the bit definitions in I/O.

mtaschl, any idea on what could solve my problem without too many modifications?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Alright. With the help of a genious embedded c programmer, I managed to solve this.

Apparently, the newest version of IAR requires "PORTB" instead of just "PB" (ex. PB5 becomes PORTB5). Rewriting this in the .h file solved my problem.

Then I came across the same problem as in the other thread about BLDC control. This was solved by putting the restartAttempt part of the code in commentary. Don't ask why, I don't know.

So I managed to create a valid .hex file. Now I need to get it onto my ATmega48PA.

I use a AVR dragon as programmer, and my computer can see it. I can connect to it. I can read the ATmega48PA. But here's the next problem: when I try to read the device signature, it returns this: 0xFF 0xFF 0xFF. Which doesn't match the selected device signature. I'm looking around for solutions, found a few things, tried a few things, didn't solve it.

I'm still looking around, but if anyone here happens to know the solution, or a thread with the solution in, it would be deeply appreciated!

Kind Regards,
Ragnor