Created Sun, 05 Jun 2011 13:14:46 +0000 by voyager
Sun, 05 Jun 2011 13:14:46 +0000
Once i read about the chipKIT boards i bought them both. To get used to the new Mpide i started converting my ARDUINO S65 software for the UNO 32.I could successfully transfer the S65 software to the UNO32 and it is really very fast in building up the new screens. In the beginning i had some trouble with the SPI but after modifying and changing to the SPI lib it works great. So before changing to the MAX 32 i was eager to see if the source of the MI0283QT2 could also be done that fast. And that was a mistake. I have a lot of problems getting the display initialized and i think the failure is in the SPI lib. To check out if the display works with any other board i adapted the software to a mbed board. No problem working great and really easy to connect. So i will have to dig in the software for the MAX 32 and see if i get a result. Otherwise i will have to sell the boards as they are of no use for my project. :cry: The UNO has not enough flash and the MAX is not working with my software. Anybody with similar SPI problems out there ?
Sun, 05 Jun 2011 13:55:08 +0000
So just switched off the Hardware SPI and installed a software version. It works on both boards. But very very slow. So the major problem is in the SPI section.
OK i'll dig on. :)
Sun, 05 Jun 2011 16:32:44 +0000
How did you do this? I'm have issues with SPI as well.
For details see post:
http://www.chipkit.org/forum/viewtopic.php?f=7&t=92
Jacob
Sun, 05 Jun 2011 22:13:21 +0000
This is way i did it
#include "SPI.h"
the SPI Pins MOSI,MISO and SCK are defined in that so there is no need to define them again and instead of using
SPI.begin(); and SPI.tranfer(data) i use wr_spi
void wr_spi(int data)
{
int mask;
for(mask=0x80; mask!=0; mask>>=1)
{
digitalWrite(SCK_PIN,LOW);
if(mask & data)
{
digitalWrite(MOSI_PIN,HIGH);
}
else
{
digitalWrite(MOSI_PIN,LOW);
}
digitalWrite(SCK_PIN,HIGH);
}
digitalWrite(SCK_PIN,LOW);
return;
}
void wr_cmd(int reg, int param)
{
digitalWrite(CS_PIN,LOW);
wr_spi(LCD_REGISTER);
wr_spi(reg);
digitalWrite(CS_PIN,HIGH);
digitalWrite(CS_PIN,LOW);
wr_spi(LCD_DATA);
wr_spi(param);
digitalWrite(CS_PIN,HIGH);
return;
}
This way it works very slow for a Display but it works.
Maybe this will help you;
Wed, 08 Jun 2011 20:25:36 +0000
Hi Voyager,
I'm also dealing with the MI0283QT2 display, but I can't even succeed to compile it for my MAX32 board, could you provide me your modified library.
I would like, at least check if my script run (even slowly) on my brand new board, then I'll look forward to improve performance
thanks, Gregory
Wed, 08 Jun 2011 21:50:49 +0000
Hi Gregory,
i can surely supply you with my sketch source. You will have to adapt it for the MAX32 SPI Pins. I am running it on a UNO32. Send me your personal email address and i'll pass the source on to you.
Voy
Wed, 08 Jun 2011 22:03:33 +0000
Hi Voy,
No prob to adapt it for the MAX32. My email account is: gdelpu "at" gmail "dot" com
Thanks for your help, Grégory
Thu, 09 Jun 2011 02:06:11 +0000
Hi Gregory, i can surely supply you with my sketch source. You will have to adapt it for the MAX32 SPI Pins. I am running it on a UNO32. Send me your personal email address and i'll pass the source on to you. Voy
You should post it for every one.
Sat, 11 Jun 2011 15:35:44 +0000
Hi Addidis, can you give me a tip how to include a complete sketch or do you want me to include that in the code section?
Mon, 13 Jun 2011 09:25:42 +0000
For just a sketch , use code brackets and post it in the post.
For edits to library files I would copy the file to google docs edit it , then post a share link to that file.
You can later assign people as editors and work on the file together in real time. I think that will make it easier to see if the code is intended to run on mpide in its current release form, or if changes to core files are required.
Mon, 13 Jun 2011 10:50:38 +0000
OK. What about the file attachment function in this forum?
Mon, 13 Jun 2011 10:51:40 +0000
OK. What about the file attachment in this forum?
Mon, 13 Jun 2011 14:47:31 +0000
The nice thing about google docs is when you want to have some one else work on it you can make them an editor , and both edit the same file , in real time . Add in google voice and you can talk like your on the phone, etc .
You can also zip up packages and upload files to google docs . As a rule my own sites are hosted for me for free, so more often then not this is the route I go to remove some of the stress from the host servers. Google handles the downloads.
Wed, 15 Jun 2011 14:21:49 +0000
After some chat sessions with Voy ager, I took a deeper look at the SPI lib embedded with PMide. It seems that this lib uses registers of SPI2 module , so only pins accessible through J13 can be driven by this lib.
I'll test it tonigh, and keep you updated.
Cheers, Greg
Fri, 17 Jun 2011 20:38:38 +0000
Any updates on the subject? I am also having the same problem but I have not started to work on it yet, so any updates will be more than welcome
Thank you in advance Mickele
Sat, 18 Jun 2011 03:16:55 +0000
I have this code shifting out bits on SPI2. I though I posted it somewhere already, but I guess not...
Working to make the 100% Arduino compatible chipKIT at least 90% compatible. http://themakersworkbench.com/?q=node/421
#if defined(__AVR_ATmega1280__) || (__AVR_ATmega2560__)
#endif
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
#endif
#if defined(__32MX320F128H__) || defined(__32MX795F512L__)
#endif
#if defined(__PIC32MX__)
#include <plib.h>
#endif
#include <SPI.h>
void setup(){
// Notes: Arduino Uno Pin 13 is the SPI SCLK pin
// Notes: Arduino Uno Pin 12 is the SPI MISO pin
// Notes: Arduino Uno Pin 11 is the SPI MOSI pin
// Notes: Arduino Uno Pin 10 is the SPI SS pin
// Notes: Arduino Uno Pin 9 goes only to connector
// Notes: Arduino Uno Pin 8 goes only to connector
pinMode(8, OUTPUT);
SPI.begin();
#if defined(__PIC32MX__)
SPI2BRG = 0x1ff; // Slow the SPI way down...
#endif
}
void loop(){
digitalWrite(8, LOW); // set the LED off
SPI.transfer(0x55);
digitalWrite(8, HIGH); // set the LED on
}
Sat, 18 Jun 2011 08:05:34 +0000
I already tried it. But it dosen't work.
#include "plib.h"
#include "SPI.h"
void setup() {
// set these Pins as output:
pinMode (RST_PIN, OUTPUT);
pinMode (CS_PIN, OUTPUT);
//pinMode (MOSI_PIN, OUTPUT);
//pinMode (SCK_PIN, OUTPUT);
// initialize SPI:
// Could be of use? But no.
// SPI2CON = 0; // Stops and resets the SPI1.
SPI.begin();
// This what i understodd from the Datasheet
// SPI2BRG = 0x1f; // Baud rate: use FPB/32 clock frequency = 250khz
// SPI2BRG = 40; // clock divider Fpb/(2 * (40+1)) = 960KHz
// SPI2BRG = 71; // clock = Fpb/144 = 250kHz
SPI2BRG=0x1ff; // use FPB/4 clock frequency
/*
I tought this would help, but no reaction
SPI2STATCLR=0x40; // clear the Overflow
SPI2CON=0x8220; // SPI ON, 8 bits transfer, SMP=1, Master mode
*/
delay(50);
lcd_init(); // init MI0283QT-2
lcd_clear(BLACK);
lcd_setOrientation(0);
lcd_drawText(80, 110, "Hardware SPI", 1, 1,WHITE, BLACK);
lcd_drawText(80, 120, "5. June 2001", 1, 1,WHITE, BLACK);
delay(3000);
}
// This wr_cmd is used to do the SPI work.
void wr_cmd(int reg, int param)
{
digitalWrite(CS_PIN,LOW);
SPI.transfer(LCD_REGISTER);
SPI.transfer(reg);
digitalWrite(CS_PIN,HIGH);
digitalWrite(CS_PIN,LOW);
SPI.transfer(LCD_DATA);
SPI.transfer(param);
digitalWrite(CS_PIN,HIGH);
return;
}
It is really funny that nearly the same same code works with a Siemens S65 Display Shield. Only SPI.begin() and the normat SPI.transfer(.....) are used. MOSI,MISO and SCLK Pins are used as with the board above.