Show Posts
|
|
Pages: 1 2 [3] 4 5 ... 12
|
|
31
|
Products / Arduino Due / Re: OneWire in Due
|
on: February 13, 2013, 05:40:05 am
|
Interrupts are disabled for a very good reason. There's absolutely no way OneWire will return to the buggy pre-2.0 days where interrupts could lengthen the timing and cause random communication errors.
Ok, I understand that (I do know what are interrupts for and why they are disabled in time critical sections). I do not understand why delayMicroseconds acts differently depending on interrupts being disabled or enabled. Declaration of delayMicrosections for SAM is quite simple (from wiring.c): void delayMicroseconds( uint32_t us ) { uint32_t start = micros(); while ((micros() - start) < us) ; }
It did not change since 1.5.1r2. Do you have an idea, what the solution could be? Leo PS if I can contribute in any way, let me know. So the problem must be somewhere behind the micros the function delayMicroseconds is realy open so the problem musst be somewhere there uint32_t micros( void ) { uint32_t ticks ; uint32_t count ;
SysTick->CTRL; do { ticks = SysTick->VAL; count = GetTickCount(); } while (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk);
return count * 1000 + (SysTick->LOAD + 1 - ticks) / (SystemCoreClock/1000000) ; } its in the wiring.c
|
|
|
|
|
32
|
Products / Arduino Due / Re: Building a CAN communication protocol interface for Arduino DUE
|
on: February 02, 2013, 09:10:31 am
|
They explained to me that if we include any ASF based file in the project, there will be needed to add thousand others. I know you did a great job with your RTC Library but in the case of the CAN class, more references need to be considered.
Thanks for the laurels, but the RTC stuff isn't as half as big as the CAN stuff you did and btw. there was an "component_rtc.h" file that was waiting for me and begged me to make an userfriendly (under arduino law-standing) Library. For you there was nothing from arduino to work above it.
|
|
|
|
|
33
|
Products / Arduino Due / Re: Building a CAN communication protocol interface for Arduino DUE
|
on: February 01, 2013, 02:18:11 am
|
Hola Lufe.
Your CAN experience will surely be very useful. As I mentioned in my first CAN post, my humble role is to channel the efforts to let the CAN API be completed. So far, I must say, it has been more a behind-the-forum work between Arduino, Atmel and me. Tests are in progress; the CAN library is working using the IDE directly (no makefile) and we are close.
From all of this, we have learned a big lesson: DO NOT (I repeat) DO NOT try to build something from Atmel Studio ASF and introduce it into Arduino. Both software architectures are entirely different and it shall be a pain to remove unneeded references. This experience is helping us to understand better how to create a Due library. The updated libsam will be solid ground for future developments for Due. Saludos!
Some good news some bad news, good to hear but can you explain the part from "Not trying to port Atmel Studio ASF to Arduino Software architecture a little bit more for me for better understanding.
|
|
|
|
|
35
|
Products / Arduino Due / Re: Pin protection on Arduino Due
|
on: January 23, 2013, 08:44:43 am
|
How do you protect your pins ? I don't connect them to anything silly.  Yes like, thinking, planing, think again, (may correct it), wiring it, control it, powering it. But in hurry: wire it, power it (crossing fingers and hope the best), use it or get a new one... True is the Due cost more than the other boards, the SAM3X is way more sensitive and it's nearly impossible for some beginner to change the µC in an safe way. For the "NO RISK, NO FUN" section would be an UNO with DIP and an USBAsp the best option, on this combination there would not so much tears generate if something went horrible wrong. Change Burn and Ready.
|
|
|
|
|
36
|
Products / Arduino Due / Re: Arduino Due libraries (official and 3rd party)
|
on: January 23, 2013, 04:15:04 am
|
First release of the RTC Library for the Arduino Due. 2 examples included. I would call it final for the moment. And on github: https://github.com/MarkusLange/Arduino-Due-RTC-LibraryI hope the library is self explaining. Markus Update new library with unixtime and compilertime support Update Version 1.2 now support for Date & Time in one operation for BKM. And some changes all in the changelog Update Version 1.3 now unixtime with timezone support with Example for it, for tevroc Update Version 1.4 now support for geman timezone with Summertime. Update Version 1.5 some changes in the Summertime Sketch, and updates at this point only on git Update Version 1.6 added rtc_clock.timing to detect when the time was set in summer- or wintertime (mostly helpfully for the german member) Update Version 1.7 added rtc_clock.date_already_set() to proof if date is allready set, to prevent setting time again for Paul Stoffregen Update Version 1.8 added rtc_clock.set_clock() to set __Time__,__Date__ in one line fixed bug in unixtime() and summertime() thanks to Paul Stoffregen for the hint
|
|
|
|
|
38
|
Products / Arduino Due / Re: Disabling UART on Due?
|
on: January 16, 2013, 05:31:26 am
|
I am working with K-line that is similar to yours. My code starts the bit-bang before activating the UART1. I am using UART0 for debug. This is on a 1284 chip. digitalWrite (TX, HIGH); // makes K-line high 3 digitalWrite(ledPin,HIGH); delay(2000); // wait for K-line to be clear 3 digitalWrite (TX, LOW); // makes K-line low 3 delay(25); digitalWrite (TX, HIGH); // makes K-line high 3 delay(25); //last delay before first message Serial1.begin(10400); Also, I think there is a function called Serial.end() to stop serial comms.. I am not positive about it though. Hi I used this code on the Leonardo for Lin, int ledState = LOW; // ledState used to set the LED long previousMillis = 0; // will store last time LED was updated
long interval = 250;
//Lin Initailisation #define linspeed 19200 unsigned long Tbit = 1000000/linspeed;
#define uartlenght 10
//Tbits Header #define breakfield 13 #define breakdelimiter 1 #define breakfieldinterbytespace 2
int frameerrordelay = ((breakfield + breakdelimiter) - uartlenght)*Tbit; //int frameerrordelay = (breakfield + breakdelimiter + breakfieldinterbytespace) - uartlenght;
#define syncfield uartlenght #define PIDfield uartlenght #define syncfieldPIDinterbytedelay 0 int syncfieldPIDinterbytespace = syncfieldPIDinterbytedelay*Tbit;
//Tbit Response #define responsedelay 8 int responsespace = responsedelay*Tbit; #define interbytedelay 0 int interbytespace = interbytedelay*Tbit;
#define numbers 4 byte message[numbers],sending[numbers]; byte linb,sync,PID,checksum; int n = 0;
void setup() { // initialize serial port and LIN: Serial.begin(19200); Lininit(); pinMode(13, OUTPUT); }
void loop() { blinking(); LinReading(); // LinWriting(); }
void LinReading() { LinRead(); PrintlnLin(); ClearFrame(); }
void LinWriting() { LinWrite(sending); Answer(); delay(1000); }
void Lininit() { Serial1.begin(linspeed); pinMode(0,INPUT_PULLUP); }
void Answer() { for (int i=0;i<numbers;i++) { sending[i] = n; } n++; n = n % 256; Serial.println(n,HEX); }
void LinRead() { if (1<<FE1) { delayMicroseconds(frameerrordelay); //after Frame Error Tbit to Sync Field if (Serial1.available() > 0) { sync = Serial1.read(); if (sync != 0x55) { sync = 0x00; } delayMicroseconds(syncfieldPIDinterbytespace); //Interbyte Space if (Serial1.available() > 0) { PID = Serial1.read(); } delayMicroseconds(responsespace); //after PID Tbit space for (int i=0;i<numbers;i++) { message[i] = Serial1.read(); if (interbytespace == 0) { //Interbyte Space delayMicroseconds(1); } else { delayMicroseconds(interbytespace); } } checksum = Serial1.read(); } } else { Serial.println("NO Break"); } }
void LinResponse(byte* sending) { if (1<<FE1) { delayMicroseconds(frameerrordelay); //after Frame Error Tbit to Sync Field if (Serial1.available() > 0) { sync = Serial1.read(); if (sync == 0x55) { delayMicroseconds(syncfieldPIDinterbytespace); //Interbyte Space if (Serial1.available() > 0) { PID = Serial1.read(); if (PID == 0x11) { delayMicroseconds(responsespace); //after PID Tbit space for (int i=0;i<numbers;i++) { Serial1.write(sending[i]); if (interbytespace == 0) { delayMicroseconds(1); } else { delayMicroseconds(interbytespace); } Serial1.write(MessageCRC(message,0)); } } } } } } }
void LinWrite(byte* sending) { Serial1.end(); pinMode(0,OUTPUT); digitalWrite(1, LOW); delayMicroseconds(breakfield*Tbit); //after Frame Error Tbit to Sync Field digitalWrite(1, HIGH); delayMicroseconds(breakdelimiter*Tbit); Serial1.begin(linspeed); Serial1.write(0x55); Serial1.write(0x03); delayMicroseconds(responsespace); for (int i=0;i<numbers;i++) { Serial1.write(sending[i]); if (interbytespace == 0) { delayMicroseconds(1); } else { delayMicroseconds(interbytespace); } } Serial1.write(MessageCRC(sending,0)); } void PrintlnLin() { if(sync != 0) { // Serial.print("Break Field Sync: "); // Serial.print(sync,HEX); Serial.print("PID: "); Serial.print(PID & 0x3F,HEX); //PID without CRC Serial.print(" CRC: "); Serial.print(PIDCRC(PID)); Serial.print(" Message: "); for (int i=0;i<numbers;i++) { Serial.print(message[i],HEX); Serial.print(";"); } Serial.print(" Checksum: "); Serial.print(checksum,HEX); Serial.print(" ChecksumCRC: "); Serial.println(MessageCRC(message,0),HEX); } }
void ClearFrame() { sync = 0; PID = 0; for (int i=0;i<numbers;i++) { message[i] = 0; } checksum = 0; }
void blinking() { unsigned long currentMillis = millis(); if(currentMillis - previousMillis > interval) { // save the last time you blinked the LED previousMillis = currentMillis; // if the LED is off turn it on and vice-versa: if (ledState == LOW) ledState = HIGH; else ledState = LOW; // set the LED with the ledState of the variable: digitalWrite(13, ledState); } }
int PIDCRC(int PID) { int P0 = ((PID>>0) + (PID>>1) + (PID>>2) + (PID>>4)) & 1; int P1 = ~((PID>>1) + (PID>>3) + (PID>>4) + (PID>>5)) & 1; return (P0 | (P1<<1)); }
byte MessageCRC(byte* message, uint16_t sum) { for (int i=0;i<numbers;i++) { sum += message[i]; } while(sum>>8) // In case adding the carry causes another carry sum = (sum&255)+(sum>>8); return (~sum); } And for the Due I have Isolated and changed the Atmel Framework Examplecode. I will attach it but I have at the moment not the time for tests also I had also to comment out the USART1_Handler in the variant.cpp to let it complie proper. B.R. Markus
|
|
|
|
|
39
|
Products / Arduino Due / Re: unconnected SPI performance -- library vs DMA
|
on: January 13, 2013, 11:39:50 am
|
I added performance results for the DUE's "extended" SPI mode. For the unconnected tests, the extended mode is faster than the older SPI API. See SPIperf.txt on the git site below
https://github.com/manitou48/DUEZoo
Hi mantoui, did you have an standalone version of the "extended" SPI-Lib as an replacement of the "regular" SPI-Lib as an 1 for 1 version to use all the benefits of the DMA support? Would be very nice, thanks. Markus
|
|
|
|
|
41
|
Products / Arduino Due / Re: Disabling UART on Due?
|
on: January 12, 2013, 05:45:42 pm
|
Trying to do some ISO-9141 (car ECU) communications, and i need to send a 5-baud start sequence which is done with: pinMode(TX0, OUTPUT); pinMode(RX0, INPUT);
digitalWrite(TX0, HIGH); .... Serial.begin(10400); BR You mean K-Line I think so you have the same Problem I have with L-Line and the USART may you can use an K-Line Transciever and the Lin support from the SAM.
|
|
|
|
|
43
|
Products / Arduino Due / Re: Arduino due DS1307 RTC library
|
on: January 07, 2013, 09:52:45 am
|
We're talking on 2 different things.
I didn't know that the SAM3X has an RTC built in it. I've tried to connect a DS1307 to the Arduino Due. That is why I didn't understand how your library can help me with my project.
If there is a RTC built-in, how can I save the time there. is there a way to connect a battery to the SAM3X, like the one connected to a DS1307 circuit?
Thanks.
The SAM3X has connections for an backup-batterie to power the RTC if the "core" is powered of but the Arduino Due doesn't has Pins for that option. Sorry for that, but this library is only for the build in RTC for an DS1307 you can use any library from the playground or else (so I think) the wire library is allready portet for the Due so they should work.
|
|
|
|
|
44
|
Products / Arduino Due / Re: Arduino due DS1307 RTC library
|
on: January 07, 2013, 08:10:52 am
|
So how do I set the time on the DS1307? I want to set it once, and read the time from it.
Btw. there is no DS1307 on the Due Board. the SAM3X has an RTC on Die. #include <rtc_clock.h>
// Select the Slowclock source //RTC_clock rtc_clock(RC); RTC_clock rtc_clock(XTAL);
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
void setup() { Serial.begin(9600); rtc_clock.init(); rtc_clock.set_time(10"hours", 29"minutes", 9"seconds"); <- this line set the time you set the hours, minutes and seconds with that rtc_clock.set_date(22, 10, 2012); }
void loop() { Serial.print("At the third stroke, it will be "); Serial.print(rtc_clock.get_hours()); <- with rtc_clock.get_hours() you get the hours as an int Serial.print(":"); same for the fowolling minutes and seconds. Serial.print(rtc_clock.get_minutes()); Serial.print(":"); Serial.println(rtc_clock.get_seconds()); Serial.print(daynames[rtc_clock.get_day_of_week()-1]); Serial.print(": "); Serial.print(rtc_clock.get_days()); Serial.print("."); Serial.print(rtc_clock.get_months()); Serial.print("."); Serial.println(rtc_clock.get_years()); } May I had to set more comments in the sample.
|
|
|
|
|
45
|
Products / Arduino Due / Re: Arduino due DS1307 RTC library
|
on: January 07, 2013, 04:47:16 am
|
Hi Markus, I'm using an external XTAL. I uploaded the Due_Rtc_Simple_Sample once and all worked fine. When I commented out: //rtc_clock.set_time(10, 29, 9); //rtc_clock.set_date(22, 10, 2012); The date was 1.1.2007 Am I missing something? No you missed nothing the 1.1.2007 is the the Resetvalue in the Calenderregister (look at the SAM3X Manuel on page 251) so this Date is set after Powering on. I don't know why this Date is set, but there is nothing wrong if it shown.
|
|
|
|
|