Closed KurtE closed 7 years ago
I added the 3 lines to the blink sample and found no error. Or you show me the whole program. Thanks.
#define LCDWIDTH 128
#define LCDHEIGHT 32
uint8_t screenmemory[(LCDHEIGHT * LCDWIDTH) /8] = {0};
int led_pin = 13;
void setup()
{
// initialize digital pin LED_BUILTIN as an output.
pinMode(led_pin, OUTPUT);
Serial.begin(9600);
}
// the loop function runs over and over again forever
void loop()
{
Serial.println("Hello World!");
digitalWrite(led_pin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led_pin, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
[Build] D:/Documents/Arduino/Blink...
[Step 1] Check Toolchain.
[Step 2] Find all source files.
[Step 3] Start building.
[1.8%] Compiling Blink.ino.cpp...
[3.6%] Compiling AudioStream.cpp...
[5.5%] Compiling avr_emulation.cpp...
[7.3%] Compiling DMAChannel.cpp...
[9.1%] Compiling HardwareSerial1.cpp...
[10.9%] Compiling HardwareSerial2.cpp...
[12.7%] Compiling HardwareSerial3.cpp...
[14.5%] Compiling HardwareSerial4.cpp...
[16.4%] Compiling HardwareSerial5.cpp...
[18.2%] Compiling HardwareSerial6.cpp...
[20.0%] Compiling IntervalTimer.cpp...
[21.8%] Compiling IPAddress.cpp...
[23.6%] Compiling main.cpp...
[25.5%] Compiling new.cpp...
[27.3%] Compiling Print.cpp...
[29.1%] Compiling Stream.cpp...
[30.9%] Compiling Tone.cpp...
[32.7%] Compiling usb_audio.cpp...
[34.5%] Compiling usb_flightsim.cpp...
[36.4%] Compiling usb_inst.cpp...
[38.2%] Compiling WMath.cpp...
[40.0%] Compiling WString.cpp...
[41.8%] Compiling yield.cpp...
[43.6%] Compiling analog.c...
[45.5%] Compiling eeprom.c...
[47.3%] Compiling keylayouts.c...
[49.1%] Compiling math_helper.c...
[50.9%] Compiling mk20dx128.c...
[52.7%] Compiling nonstd.c...
[54.5%] Compiling pins_teensy.c...
[56.4%] Compiling serial1.c...
[58.2%] Compiling serial2.c...
[60.0%] Compiling serial3.c...
[61.8%] Compiling serial4.c...
[63.6%] Compiling serial5.c...
[65.5%] Compiling serial6.c...
[67.3%] Compiling serial6_lpuart.c...
[69.1%] Compiling ser_print.c...
[70.9%] Compiling touch.c...
[72.7%] Compiling usb_desc.c...
[74.5%] Compiling usb_dev.c...
[76.4%] Compiling usb_joystick.c...
[78.2%] Compiling usb_keyboard.c...
[80.0%] Compiling usb_mem.c...
[81.8%] Compiling usb_midi.c...
[83.6%] Compiling usb_mouse.c...
[85.5%] Compiling usb_mtp.c...
[87.3%] Compiling usb_rawhid.c...
[89.1%] Compiling usb_seremu.c...
[90.9%] Compiling usb_serial.c...
[92.7%] Compiling usb_touch.c...
[94.5%] Compiling memcpy-armv7m.S...
[96.4%] Compiling memset.S...
[98.2%] Linking everything together...
[100.0%] Creating binary files...
Opening Teensy Loader...
Sketch uses 24,628 bytes (2.3%) of program storage space. Maximum is 1,048,576 bytes.
Global variables use 5,040 bytes (1.9%) of dynamic memory, leaving 257,104 bytes for local variables. Maximum is 262,144 bytes.
[Build done.]
Here is the whole program.
// Quick and dirty extract of parts of Teensyview to compare speed of different SPI methods to compare
// speed.
#include <SPI.h>
// #include <SPIKinetis.h>
#define LCDWIDTH 128
#define LCDHEIGHT 32
#define PIN_RESET 15
#define PIN_SCK 13
#define PIN_MOSI 11
#define PIN_DC 9
#define PIN_CS 10
uint8_t pcs_data = 0;
uint8_t pcs_command = 0;
//uint8_t screenmemory[512] = {0};
uint8_t screenmemory[(LCDHEIGHT * LCDWIDTH) /8] = {0};
uint8_t _height = 32;
volatile uint8_t * _csport, * _dcport;
uint8_t _cspinmask, _dcpinmask;
uint32_t clockRateSetting = 8000000;
void setup()
{
pinMode(PIN_CS, OUTPUT);
_csport = portOutputRegister(digitalPinToPort(PIN_CS));
_cspinmask = digitalPinToBitMask(PIN_CS);
* _csport |= _cspinmask;
pinMode(PIN_DC, OUTPUT);
_dcport = portOutputRegister(digitalPinToPort(PIN_DC));
_dcpinmask = digitalPinToBitMask(PIN_DC);
SPI.begin();
for (uint16_t i = 0; i < sizeof(screenmemory); i++)
screenmemory[i] = i % 256; // Put in data to compare against...
}
void loop()
{
uint32_t start_time = micros();
display_transfer_byte();
Serial.print("Simple one byte output time: ");
Serial.println(micros() - start_time, DEC);
delay(5);
start_time = micros();
display_transfer_buf();
Serial.print("Transfer using new buffer transfer time: ");
Serial.println(micros() - start_time, DEC);
delay(5);
start_time = micros();
display_transfer_buf_old();
Serial.print("Transfer using old buffer transfer time: ");
Serial.println(micros() - start_time, DEC);
#ifdef KINETISK
delay(5);
pcs_data = 0;
pcs_command = pcs_data | SPI.setCS(PIN_DC);
start_time = micros();
display_transfer_hardware();
Serial.print("Transfer using pushr time: ");
Serial.println(micros() - start_time, DEC);
// Make DC an output pin again
pinMode(PIN_DC, OUTPUT);
#endif
Serial.println();
delay(1000);
}
void display_transfer_buf(void)
{
uint8_t set_page_column_address[] =
{
0xb0, 0x21, 0, 0x7f
}; // set to page 0 column 0
uint8_t i;
uint8_t * pscreen_data = screenmemory;
uint8_t count_pages = (_height/8);
SPI.beginTransaction(SPISettings(clockRateSetting, MSBFIRST, SPI_MODE0));
* _csport &= ~_cspinmask;
for (i = 0; i < count_pages; i++)
{
// Output the header
* _dcport &= ~_dcpinmask; // assert DC
set_page_column_address[0] = 0xb0 + i;
SPI.transfer(set_page_column_address, NULL, sizeof(set_page_column_address));
// Now go into data mode
* _dcport |= _dcpinmask;
SPI.transfer(pscreen_data, NULL, LCDWIDTH);
pscreen_data += LCDWIDTH;
}
* _csport |= _cspinmask;
SPI.endTransaction();
}
void display_transfer_buf_old(void)
{
uint8_t set_page_column_address[] =
{
0xb0, 0x21, 0, 0x7f
}; // set to page 0 column 0
uint8_t i;
uint8_t * pscreen_data = screenmemory;
uint8_t count_pages = (_height/8);
uint8_t tmp_buff[LCDWIDTH];
SPI.beginTransaction(SPISettings(clockRateSetting, MSBFIRST, SPI_MODE0));
* _csport &= ~_cspinmask;
for (i = 0; i < count_pages; i++)
{
// Output the header
* _dcport &= ~_dcpinmask; // assert DC
set_page_column_address[0] = 0xb0 + i;
memcpy(tmp_buff, set_page_column_address, sizeof(set_page_column_address));
SPI.transfer(tmp_buff, sizeof(set_page_column_address));
// Now go into data mode
* _dcport |= _dcpinmask;
memcpy(tmp_buff, pscreen_data, LCDWIDTH);
SPI.transfer(tmp_buff, LCDWIDTH);
pscreen_data += LCDWIDTH;
}
* _csport |= _cspinmask;
SPI.endTransaction();
}
void display_transfer_byte(void)
{
uint8_t i;
uint8_t * pscreen_data = screenmemory;
uint8_t count_pages = (_height/8);
SPI.beginTransaction(SPISettings(clockRateSetting, MSBFIRST, SPI_MODE0));
* _csport &= ~_cspinmask;
for (i = 0; i < count_pages; i++)
{
// Output the header
* _dcport &= ~_dcpinmask; // assert DC
SPI.transfer(0xb0 + i);
SPI.transfer(0x21);
SPI.transfer(0);
SPI.transfer(0x7f);
// Now go into data mode
* _dcport |= _dcpinmask;
for (uint8_t j = 0; j < LCDWIDTH; j++)
{
SPI.transfer(* pscreen_data++);
}
}
* _csport |= _cspinmask;
SPI.endTransaction();
}
// Try using Hardware buffers.
// Note for now I will only do this for DC...
#ifdef KINETISK
//void waitFifoNotFull(void) __attribute__((always_inline)) {
void waitFifoNotFull(void) {
uint32_t sr;
uint32_t tmp __attribute__((unused));
do {
sr = KINETISK_SPI0.SR;
if (sr & 0xF0) tmp = KINETISK_SPI0.POPR; // drain RX FIFO
} while ((sr & (15 << 12)) > (3 << 12));
}
void waitFifoEmpty(void) {
uint32_t sr;
uint32_t tmp __attribute__((unused));
do {
sr = KINETISK_SPI0.SR;
if (sr & 0xF0) tmp = KINETISK_SPI0.POPR; // drain RX FIFO
} while ((sr & 0xF0F0) > 0); // wait both RX & TX empty
}
inline void waitTransmitComplete(void) {
uint32_t tmp __attribute__((unused));
while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
tmp = KINETISK_SPI0.POPR; // drain the final RX FIFO word
}
inline void waitTransmitComplete(uint32_t mcr) {
uint32_t tmp __attribute__((unused));
while (1) {
uint32_t sr = KINETISK_SPI0.SR;
if (sr & SPI_SR_EOQF) break; // wait for last transmit
if (sr & 0xF0) tmp = KINETISK_SPI0.POPR;
}
KINETISK_SPI0.SR = SPI_SR_EOQF;
SPI0_MCR = mcr;
while (KINETISK_SPI0.SR & 0xF0) {
tmp = KINETISK_SPI0.POPR;
}
}
inline void writecommand_cont(uint8_t c) {
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
waitFifoNotFull();
}
inline void writedata8_cont(uint8_t c) {
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
waitFifoNotFull();
}
inline void writedata16_cont(uint16_t d) {
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
waitFifoNotFull();
}
inline void writecommand_last(uint8_t c) {
uint32_t mcr = SPI0_MCR;
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;
waitTransmitComplete(mcr);
}
inline void writedata8_last(uint8_t c) {
uint32_t mcr = SPI0_MCR;
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;
waitTransmitComplete(mcr);
}
inline void writedata16_last(uint16_t d) {
uint32_t mcr = SPI0_MCR;
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ;
waitTransmitComplete(mcr);
}
void display_transfer_hardware(void)
{
uint8_t i;
uint8_t * pscreen_data = screenmemory;
uint8_t count_pages = (_height/8);
uint16_t w = 0;
SPI.beginTransaction(SPISettings(clockRateSetting, MSBFIRST, SPI_MODE0));
* _csport &= ~_cspinmask;
for (i = 0; i < count_pages; i++)
{
// Output the header
* _dcport &= ~_dcpinmask; // assert DC
writecommand_cont(0xb0 + i);
writecommand_cont(0x21);
writecommand_cont(0);
writecommand_cont(0x7f);
// Now go into data mode
* _dcport |= _dcpinmask;
// Faster if we write 16 bits out at a time instead of 8
for (uint8_t j = 0; j < LCDWIDTH; j+=2)
{
w = (*pscreen_data++) << 8;
w |= *pscreen_data++;
if (pscreen_data >= &screenmemory[(LCDWIDTH*LCDHEIGHT)/8])
writedata16_last(w);
else
writedata16_cont(w);
}
}
* _csport |= _cspinmask;
SPI.endTransaction();
}
#endif
I am not sure whether the problem is solved because I got the same build errors from both this plugin and Arduino IDE. I need your feedback. Thanks.
D:/Documents/Arduino/test00/test00.ino: In function 'void display_transfer_buf()':
D:/Documents/Arduino/test00/test00.ino:84:84: error: no matching function for call to 'SPIClass::transfer(uint8_t [4], NULL, unsigned int)'
SPI.transfer(set_page_column_address, NULL, sizeof(set_page_column_address));
^
In file included from D:/Documents/Arduino/test00/test00.ino:3:0:
E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:479:24: note: candidate: static uint8_t SPIClass::transfer(uint8_t)
inline static uint8_t transfer(uint8_t data) {
^
E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:479:24: note: candidate expects 1 argument, 3 provided
E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:491:14: note: candidate: static void SPIClass::transfer(void*, size_t)
static void transfer(void *buf, size_t count);
^
E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:491:14: note: candidate expects 2 arguments, 3 provided
D:/Documents/Arduino/test00/test00.ino:87:50: error: no matching function for call to 'SPIClass::transfer(uint8_t*&, NULL, int)'
SPI.transfer(pscreen_data, NULL, LCDWIDTH);
^
In file included from D:/Documents/Arduino/test00/test00.ino:3:0:
E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:479:24: note: candidate: static uint8_t SPIClass::transfer(uint8_t)
inline static uint8_t transfer(uint8_t data) {
^
E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:479:24: note: candidate expects 1 argument, 3 provided
E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:491:14: note: candidate: static void SPIClass::transfer(void*, size_t)
static void transfer(void *buf, size_t count);
^
E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:491:14: note: candidate expects 2 arguments, 3 provided
Thanks, I am working on an updated SPI library. Hopefully trying to improve the performance… Added new api, which you did not have….
I synced up this morning, tried compiling with the macros and it appears to work now 😃
Kurt
From: S. Zhang [mailto:notifications@github.com] Sent: Monday, April 10, 2017 9:08 PM To: Robot-Will/Stino Stino@noreply.github.com Cc: KurtE kurte@rockisland.com; Author author@noreply.github.com Subject: Re: [Robot-Will/Stino] #defines used in memory allocation causes compile error... (#423)
I am not sure whether the problem is solved because I got the same build errors from both this plugin and Arduino IDE. I need your feedback. Thanks.
D:/Documents/Arduino/test00/test00.ino: In function 'void display_transfer_buf()': D:/Documents/Arduino/test00/test00.ino:84:84: error: no matching function for call to 'SPIClass::transfer(uint8_t [4], NULL, unsigned int)' SPI.transfer(set_page_column_address, NULL, sizeof(set_page_column_address)); ^ In file included from D:/Documents/Arduino/test00/test00.ino:3:0: E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:479:24: note: candidate: static uint8_t SPIClass::transfer(uint8_t) inline static uint8_t transfer(uint8_t data) { ^ E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:479:24: note: candidate expects 1 argument, 3 provided E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:491:14: note: candidate: static void SPIClass::transfer(void, size_t) static void transfer(void buf, size_t count); ^ E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:491:14: note: candidate expects 2 arguments, 3 provided D:/Documents/Arduino/test00/test00.ino:87:50: error: no matching function for call to 'SPIClass::transfer(uint8_t&, NULL, int)' SPI.transfer(pscreen_data, NULL, LCDWIDTH); ^ In file included from D:/Documents/Arduino/test00/test00.ino:3:0: E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:479:24: note: candidate: static uint8_t SPIClass::transfer(uint8_t) inline static uint8_t transfer(uint8_t data) { ^ E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:479:24: note: candidate expects 1 argument, 3 provided E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:491:14: note: candidate: static void SPIClass::transfer(void, size_t) static void transfer(void *buf, size_t count); ^ E:/dev/arduino/arduino-1.8.2/hardware/teensy/avr/libraries/SPI/SPI.h:491:14: note: candidate expects 2 arguments, 3 provided
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Robot-Will/Stino/issues/423#issuecomment-293144210 , or mute the thread https://github.com/notifications/unsubscribe-auth/ABfGQHVy1z1iZK5rs6Fyo6ulgTgFmkzMks5ruvydgaJpZM4M4K30 .
Short version: This compiles without error
However this one errors out saying that screenmemory was already defined (at the same line number)
Arduino IDE compiled without errors
I can paste in whole program if you would like