source code error

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

Hi i am batteling with this software this is a small piece of software in a library.

When i compile the complete code with all the libraries there is no errors,(still finding my way around c).

When i create a new project and only use the main part and copy these two routines from the library and paste it just under the #defines i get a error ''com'' not defined.

I want to break the source code (that is scattered over several libraries)up into small pieces to understand the working of C .

 

How must this be structured to work outside the original library????

 

 

void ili9341_spi_send(unsigned char spi_data)//send spi data to display
{
SPDR=spi_data;//move data into spdr
while(!(SPSR & (1<<SPIF)));//wait till the transmission is finished
}

 

 

 

void ili9341_writecommand8(uint8_t com)//command write-------GET ERROR FROM THIS LINE------COM not defined
{
controlport &=~((1<<dc)|(1<<cs));//dc and cs both low to send command
_delay_us(5);//little delay
ili9341_spi_send(com);
controlport |=(1<<cs);//pull high cs
}

 

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

You need to #include <stdint.h> methinks.

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

com is probably a #define in the original library code

you would need to set this in your own code as well

(probably wiser to just #include the library rather than trying to copy the code.)

 

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

mikedb wrote:
i get a error ''com'' not defined

Is that the only error you get?

 

Most likely, as Kartman suggests, there were earlier errors - and this is just a consequence of those.

 

This is why it's really important that you address the first error first.

 

IPguru wrote:
com is probably a #define in the original library code

No - it's one of the function parameters.

 

I think Kartman's suggestion is more likely ...

 

 

EDIT

 

Fix quote

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Jun 21, 2017 - 10:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mikedb wrote:
I want to break the source code (that is scattered over several libraries)up into small pieces to understand the working of C .

That sounds like trying to learn to drive by dismantling a car!

 

It's generally a lot easier to learn stuff by starting with basics and working up to more advanced stuff ... !

 

https://www.avrfreaks.net/comment...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How is it possible to give a answer if you do not understand the question?

 

1.No error in first build with all the libraries included!!!!

2.Blink led--------DONE

3.Blink several leds---------DONE

4.Use buttons to blink leds--------DONE

5.ADC 8 bit write on alpha numeric lcd-------DONE

6.ADC 10 bit write to alpha numeric lcd ,(Hi limit --write pump off)...(Low limit --write pump on).....Mmmm...o yes DONE

 

I am not learning to drive just want to find out why the same carbutattor works in a BLUE truck and not in the GREEN truck (same models).

 

''#include <stdint.h>'' this is included in the MAIN file,i dont want to use 4 libraries just get the SPI working ,i am testing small bits of sample code to get a better understanding.

 

 

 

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

mikedb wrote:
''#include <stdint.h>'' this is included in the MAIN file
You have to include it in every file which uses things like uint8_t. Each file is compiled separately.

 

mikedb wrote:
i dont want to use 4 libraries just get the SPI working
It isn't a library but a header file. And including it in multiple files costs you absolutely nothing.

Stefan Ernst