Show Posts
|
|
Pages: 1 2 [3] 4 5 6
|
|
32
|
Products / Arduino Due / Re: Standard libraries unknown in IDE V1.5.1r2
|
on: December 29, 2012, 08:36:30 pm
|
Ok ok. WORKINGGGGGGGGGGGGGGGG!!!!!!!!! Just add this to the onewire.h: #elif defined(__SAM3X8E__) #define PIN_TO_BASEREG(pin) (&(digitalPinToPort(pin)->PIO_PER)) //to get Base PORT address #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) (((*(base+15)) & (mask)) ? 1 : 0) /*(Pio Offset: 0x003C) Pin Data Status Register */ #define DIRECT_MODE_INPUT(base, mask) ((*(base+5)) = (mask)) /*(Pio Offset: 0x0014) Output Disable Register */ #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+4)) = (mask)) /*(Pio Offset: 0x0010) Output Enable Register */ #define DIRECT_WRITE_LOW(base, mask) ((*(base+13)) = (mask)) /*(Pio Offset: 0x0034) Clear Output Data Register */ #define DIRECT_WRITE_HIGH(base, mask) ((*(base+12)) = (mask)) /*(Pio Offset: 0x0030) Set Output Data Register */ #include "pgmspace.h"
Final code should look like this: #if defined(__AVR__) #define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint8_t #define IO_REG_ASM asm("r30") #define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) #define DIRECT_MODE_INPUT(base, mask) ((*(base+1)) &= ~(mask)) #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) |= (mask)) #define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) &= ~(mask)) #define DIRECT_WRITE_HIGH(base, mask) ((*(base+2)) |= (mask))
#elif defined(__SAM3X8E__) #define PIN_TO_BASEREG(pin) (&(digitalPinToPort(pin)->PIO_PER)) //to get Base PORT address #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) (((*(base+15)) & (mask)) ? 1 : 0) /*(Pio Offset: 0x003C) Pin Data Status Register */ #define DIRECT_MODE_INPUT(base, mask) ((*(base+5)) = (mask)) /*(Pio Offset: 0x0014) Output Disable Register */ #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+4)) = (mask)) /*(Pio Offset: 0x0010) Output Enable Register */ #define DIRECT_WRITE_LOW(base, mask) ((*(base+13)) = (mask)) /*(Pio Offset: 0x0034) Clear Output Data Register */ #define DIRECT_WRITE_HIGH(base, mask) ((*(base+12)) = (mask)) /*(Pio Offset: 0x0030) Set Output Data Register */ #include "pgmspace.h"
#elif defined(__PIC32MX__) //- #include <plib.h> // is this necessary? #define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) (((*(base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10 #define DIRECT_MODE_INPUT(base, mask) ((*(base+2)) = (mask)) //TRISXSET + 0x08 #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) = (mask)) //TRISXCLR + 0x04 #define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24 #define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28
#else #error "Please define I/O register types here" #endif
The difference is the equal sine instead the logical AND. But, I still don't understand why it works this way... Remenber, the pgmspace.h is in a few older posts in this thread.
|
|
|
|
|
33
|
Products / Arduino Due / Re: Standard libraries unknown in IDE V1.5.1r2
|
on: December 29, 2012, 07:27:26 pm
|
Ok, I'll answer myself...  It's because the var that is pointed is from uint32_t type (4 bytes). So increasing 1, is in fact, increasing 4 positions. I've fixed this this way: #elif defined(__SAM3X8E__) #define PIN_TO_BASEREG(pin) (&(digitalPinToPort(pin)->PIO_PER)) //to get Base PORT address #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) (((*(base+(0x3c/4))) & mask) ? 1 : 0) /*(Pio Offset: 0x003C) Pin Data Status Register */ #define DIRECT_MODE_INPUT(base, mask) ((*(base+(0x14/4))) & mask) /*(Pio Offset: 0x0014) Output Disable Register */ #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+(0x10/4))) & mask) /*(Pio Offset: 0x0010) Output Enable Register */ #define DIRECT_WRITE_LOW(base, mask) ((*(base+(0x34/4))) & mask) /*(Pio Offset: 0x0034) Clear Output Data Register */ #define DIRECT_WRITE_HIGH(base, mask) ((*(base+(0x30/4))) & mask) /*(Pio Offset: 0x0030) Set Output Data Register */ #include "pgmspace.h"
But still no temp readings...
|
|
|
|
|
34
|
Products / Arduino Due / Re: Standard libraries unknown in IDE V1.5.1r2
|
on: December 29, 2012, 06:45:54 pm
|
The math with pointers is failing. I try to add the offset to the base register and it gets a value that I can't explain. I'm using pin 7 of due. For this pin, the port address is 400E1200 and PDSR register is 400E123C. This is taken from datasheet. I've added Serial.println to the reset function to see the backstage. uint8_t OneWire::reset(void) { IO_REG_TYPE mask = bitmask; //volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; volatile IO_REG_TYPE *reg = baseReg; //volatile IO_REG_TYPE *regout = baseOutReg; Serial.println((long)(&(digitalPinToPort(7)->PIO_PER)),HEX); Serial.println((long)(reg),HEX); Serial.println((long)(bitmask),HEX); volatile uint32_t *value=reg+1; Serial.println((uint32_t)value,HEX); uint8_t r; uint8_t retries = 125;
noInterrupts(); DIRECT_MODE_INPUT(reg, mask); Serial.println(((*(reg+0x3c))),HEX);
From this serial.print i get: for -> Serial.println((long)(&(digitalPinToPort(7)->PIO_PER)),HEX); I have 400E1200 for -> Serial.println((long)(reg),HEX); I also have 400E1200 for -> Serial.println((long)(bitmask),HEX); I have 800000 for - > Serial.println((uint32_t)value,HEX); I have 400E1204 !!!!!!!!!!!!!! Remenber that I've done this one line before: volatile uint32_t *value=reg+1; Why I don't have 400E1201 ????? 
|
|
|
|
|
35
|
Products / Arduino Due / Re: Standard libraries unknown in IDE V1.5.1r2
|
on: December 29, 2012, 04:52:45 pm
|
|
Ok, thank you for the explanation.
Well, this should work, I'm clueless...
I'll move for a simple test program with onewire and see what happen. Just in the event that the problem is my program and not the lib...
interrupts() and nointerrupts()
Are system functions to enable and disable interrupts at a given time, right?
|
|
|
|
|
36
|
Products / Arduino Due / Re: Standard libraries unknown in IDE V1.5.1r2
|
on: December 29, 2012, 03:14:02 pm
|
Well, still no luck.. I've set all the registers in place same way has the other defines, but no go. #elif defined(__SAM3X8E__) #define PIN_TO_BASEREG(pin) (&(digitalPinToPort(pin)->PIO_PER)) //to get Base PORT address #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) (((*(base+0x3c)) & mask) ? 1 : 0) /*(Pio Offset: 0x003C) Pin Data Status Register */ #define DIRECT_MODE_INPUT(base, mask) ((*(base+0x14)) & mask) /*(Pio Offset: 0x0014) Output Disable Register */ #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+0x10)) & mask) /*(Pio Offset: 0x0010) Output Enable Register */ #define DIRECT_WRITE_LOW(base, mask) ((*(base+0x34)) & mask) /*(Pio Offset: 0x0034) Clear Output Data Register */ #define DIRECT_WRITE_HIGH(base, mask) ((*(base+0x30)) & mask) /*(Pio Offset: 0x0030) Set Output Data Register */ #include "pgmspace.h"
By the way, in the line #define DIRECT_READ(base, mask) (((*(base+0x3c)) & mask) ? 1 : 0) /*(Pio Offset: 0x003C) Pin Data Status Register */ what is the meaning of ? 1 : 0 ?
|
|
|
|
|
37
|
Products / Arduino Due / Re: Standard libraries unknown in IDE V1.5.1r2
|
on: December 29, 2012, 01:28:53 pm
|
Hi again. I've changed the defines to the code bellow: #elif defined(__SAM3X8E__) #define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) ((*(base)) & (mask)) #define DIRECT_MODE_INPUT(base, mask) (base->PIO_OER &= ~mask) #define DIRECT_MODE_OUTPUT(base, mask) (base->PIO_OER |= mask) #define DIRECT_WRITE_LOW(base, mask) ((*(base)) &= ~mask) #define DIRECT_WRITE_HIGH(base, mask) ((*(base)) |= mask) #include "pgmspace.h"
Right now I'm stuck with: #define DIRECT_MODE_INPUT(base, mask) (base->PIO_OER &= ~mask) #define DIRECT_MODE_OUTPUT(base, mask) (base->PIO_OER |= mask)
The compiler complains that he doens't know member PIO_OER. I'm looking in the files for this structures but I'm not finding them. Anyone knows were these structures are? The idea here, is to make the pin output, or input. If I recall right, this is done with OER. I've previously used this registers in UTFT lib but in this format: REG_PIOX_OER=0xXXXXX
The errors I'm getting from compiler: " D:\Docs\Arduino\arduino-1.5.1r2_teste\libraries\OneWire\OneWire.cpp: In member function 'uint8_t OneWire::reset()': D:\Docs\Arduino\arduino-1.5.1r2_teste\libraries\OneWire\OneWire.cpp:128: error: request for member 'PIO_OER' in '* reg', which is of non-class type 'volatile long unsigned int' D:\Docs\Arduino\arduino-1.5.1r2_teste\libraries\OneWire\OneWire.cpp:138: error: request for member 'PIO_OER' in '* reg', which is of non-class type 'volatile long unsigned int' D:\Docs\Arduino\arduino-1.5.1r2_teste\libraries\OneWire\OneWire.cpp:142: error: request for member 'PIO_OER' in '* reg', which is of non-class type 'volatile long unsigned int' " Help appreciated. 
|
|
|
|
|
39
|
Products / Arduino Due / Re: Standard libraries unknown in IDE V1.5.1r2
|
on: December 29, 2012, 09:02:55 am
|
Picking this function: uint8_t OneWire::reset(void) { IO_REG_TYPE mask = bitmask; volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; uint8_t r; uint8_t retries = 125;
noInterrupts(); DIRECT_MODE_INPUT(reg, mask); interrupts(); // wait until the wire is high... just in case do { if (--retries == 0) return 0; delayMicroseconds(2); } while ( !DIRECT_READ(reg, mask));
noInterrupts(); DIRECT_WRITE_LOW(reg, mask); DIRECT_MODE_OUTPUT(reg, mask); // drive output low interrupts(); delayMicroseconds(500); noInterrupts(); DIRECT_MODE_INPUT(reg, mask); // allow it to float delayMicroseconds(80); r = !DIRECT_READ(reg, mask); interrupts(); delayMicroseconds(420); return r; }
this line volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; Seems to be declaring 2 vars of IO_REG_TYPE (beeing uint32_t by macro defenition previously) *reg IO_REG_ASM But I don't understand why the IO_REG_ASM. Shouldn't this line be just: volatile IO_REG_TYPE *reg = baseReg; ?
|
|
|
|
|
40
|
Products / Arduino Due / Re: Standard libraries unknown in IDE V1.5.1r2
|
on: December 29, 2012, 08:37:02 am
|
Hi. I'm struggling in the same onewire lib right now. I've made it to compile, but it doesn't work anyway. in the defines I've this: // Platform specific I/O definitions
#if defined(__AVR__) #define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint8_t #define IO_REG_ASM asm("r30") #define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) #define DIRECT_MODE_INPUT(base, mask) ((*(base+1)) &= ~(mask)) #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) |= (mask)) #define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) &= ~(mask)) #define DIRECT_WRITE_HIGH(base, mask) ((*(base+2)) |= (mask))
#elif defined(__SAM3X8E__) #define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) #define DIRECT_MODE_INPUT(base, mask) ((*(base+1)) &= ~(mask)) #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) |= (mask)) #define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) &= ~(mask)) #define DIRECT_WRITE_HIGH(base, mask) ((*(base+2)) |= (mask)) #include "pgmspace.h"
#elif defined(__PIC32MX__) //- #include <plib.h> // is this necessary? #define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) (((*(base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10 #define DIRECT_MODE_INPUT(base, mask) ((*(base+2)) = (mask)) //TRISXSET + 0x08 #define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) = (mask)) //TRISXCLR + 0x04 #define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24 #define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28
#else #error "Please define I/O register types here" #endif
the line #include "pgmspace.h" call the attached file. The program compiles and works, except that I don't have temperature readings. I'm looking for understanding of this line: #define IO_REG_ASM asm("r30") This line is present for AVR, and since this is called in the communication functions, this might be the problem. If anyone can explain this line, maybe I can move forward faster. Help is appreciated, the developers of onewire doesn't seem to care about Due. Regards, Joao
|
|
|
|
|
41
|
Products / Arduino Due / Re: TFT library compatible with Due?
|
on: December 16, 2012, 08:03:55 pm
|
|
Hummm, ok.
I don't understand why then, it should work, I'm using the same pins as in 16bit mode for the high port.
Without one to test, I can't move forward, sorry.
Regards,
Joao
|
|
|
|
|
42
|
Products / Arduino Due / Re: TFT library compatible with Due?
|
on: December 14, 2012, 07:01:59 pm
|
I am curious what I would need to modify in the library to get my 8 Bit LCD running properly.
Hi. I've included code for 8 bit mode. Replace (doing backup of your current file) the HW_ARM.h file in your library with the one attached with your IDE closed. I don't have a display to test it, but should work, try it!  Regards, Joao
|
|
|
|
|
45
|
Products / Arduino Due / Re: SdFat for Due posted
|
on: December 08, 2012, 08:55:10 pm
|
I agree, the specs are amazing!  Ok, I just thought abut the 4 bit interface because it could be simpler and faster to implement. I'll google on that to see what I get. Thank you! 
|
|
|
|
|