Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing registers/interrupts
02-04-2015, 10:42 AM,
#11
RE: Accessing registers/interrupts
You get it...:-D
Reply
02-04-2015, 09:22 PM,
#12
RE: Accessing registers/interrupts
Wink

And how about the registers? Is there a way to access them?
Reply
02-04-2015, 10:15 PM,
#13
RE: Accessing registers/interrupts
The I/O ports or the CPU's registers? The C compiler uses the CPU ones and I'm not clear why you'd want to.

John
Reply
07-04-2015, 10:09 PM,
#14
RE: Accessing registers/interrupts
Uhm, sorry for the late answer. The syntax in my first post in this thread works now. The rest is well explained in the data sheet and in app notes. Thx so far.
Reply
25-05-2015, 11:38 AM,
#15
RE: Accessing registers/interrupts
Hi,

I have 2 issues I am currently facing may be you can help me:


Issue 1:

Reading out the receive buffer of I2C bus 2.

Currently, I want to connect my Raspberry Pi B+ to the PIC32MX220, which works quite good since they find each other and the RPI can write to receive buffer indicated by a green LED blinking when data has been written to the receive buffer. The problem is now to read out this buffer and my guess would be just assigning the I2C2RCV to a variable (see code below). I found code examples in the web, where this syntax has been used, but the compiler does't like this.

Here is the link with the code example:
http://hades.mech.northwestern.edu/index...een_PIC32s

Here the stdout:
Code:
if exist C:\pinguino-11\user\source\main32.o @del C:\pinguino-11\user\source\main32.o
if exist C:\pinguino-11\user\source\main32.elf @del C:\pinguino-11\user\source\main32.elf
if exist C:\pinguino-11\user\source\main32.hex @del C:\pinguino-11\user\source\main32.hex
if exist C:\pinguino-11\user\source\obj\non-free\processor.o @del C:\pinguino-11\user\source\obj\non-free\processor.o
C:\pinguino-11\compilers\p32\bin\p32-gcc.exe -march=m4k -EL -msoft-float -nostdlib -static -O3 -minterlink-mips16 -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-LC:\pinguino-11\user\source\obj\non-free -Wl,--defsym,_min_heap_size=512 -Wl,-Map=C:\pinguino-11\user\source\output.map -D __PIC32MX__ -D __32MX220F032D__ -D PIC32_PINGUINO_220 -TC:\pinguino-11\p32\lkr\32MX220F032D.ld -TC:\pinguino-11\p32\lkr\elf32pic32mx.x -LC:\pinguino-11\user\source\obj\non-free\usb -lm -lgcc -lc -fdollars-in-identifiers -IC:\pinguino-11\p32\include\non-free -IC:\pinguino-11\p32\include\pinguino\core -IC:\pinguino-11\p32\include\pinguino\libraries -IC:\pinguino-11\p32\lkr -IC:/Users/-/Documents/Dies_und_das/PIC32_PINGUINO_MX220/dobby -IC:\pinguino-11\user\source\obj\non-free -mips16 -S -o C:\pinguino-11\user\source\main32.S C:\pinguino-11\user\source\main32.c
C:\pinguino-11\compilers\p32\bin\p32-gcc.exe -march=m4k -EL -msoft-float -nostdlib -static -O3 -minterlink-mips16 -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-LC:\pinguino-11\user\source\obj\non-free -Wl,--defsym,_min_heap_size=512 -Wl,-Map=C:\pinguino-11\user\source\output.map -D __PIC32MX__ -D __32MX220F032D__ -D PIC32_PINGUINO_220 -TC:\pinguino-11\p32\lkr\32MX220F032D.ld -TC:\pinguino-11\p32\lkr\elf32pic32mx.x -LC:\pinguino-11\user\source\obj\non-free\usb -lm -lgcc -lc -fdollars-in-identifiers -IC:\pinguino-11\p32\include\non-free -IC:\pinguino-11\p32\include\pinguino\core -IC:\pinguino-11\p32\include\pinguino\libraries -IC:\pinguino-11\p32\lkr -IC:/Users/-/Documents/Dies_und_das/PIC32_PINGUINO_MX220/dobby -IC:\pinguino-11\user\source\obj\non-free -mips16 -E C:\pinguino-11\user\source\main32.c > C:\pinguino-11\user\source\main32.pp
C:\pinguino-11\compilers\p32\bin\p32-gcc.exe -march=m4k -EL -msoft-float -nostdlib -static -O3 -minterlink-mips16 -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-LC:\pinguino-11\user\source\obj\non-free -Wl,--defsym,_min_heap_size=512 -Wl,-Map=C:\pinguino-11\user\source\output.map -D __PIC32MX__ -D __32MX220F032D__ -D PIC32_PINGUINO_220 -TC:\pinguino-11\p32\lkr\32MX220F032D.ld -TC:\pinguino-11\p32\lkr\elf32pic32mx.x -LC:\pinguino-11\user\source\obj\non-free\usb -lm -lgcc -lc -fdollars-in-identifiers -IC:\pinguino-11\p32\include\non-free -IC:\pinguino-11\p32\include\pinguino\core -IC:\pinguino-11\p32\include\pinguino\libraries -IC:\pinguino-11\p32\lkr -IC:/Users/-/Documents/Dies_und_das/PIC32_PINGUINO_MX220/dobby -IC:\pinguino-11\user\source\obj\non-free -mips16 -c -g -Wa,-a,-ad C:\pinguino-11\user\source\main32.c > C:\pinguino-11\user\source\main32.lst
C:\Users\-\AppData\Local\Temp\ccspqKZc.s: Assembler messages:
C:\Users\-\AppData\Local\Temp\ccspqKZc.s:10864: Error: internal error: fixup not contained within frag
C:\Users\-\AppData\Local\Temp\ccspqKZc.s:10970: Error: internal error: fixup not contained within frag
make: *** [compile] Error 1

Issue 2:

Modifing the PIC slave address.

I would like to use an individual slave address without using the slave address masking, where bits just set to don't care. Due to the informations in the datasheet (p.174) it should be possible to write to the I2CxADD register, but an assignment like
Code:
I2C2ADD = 0x0E;
will be ignored. It still responds to the default address. Has anyone tried this before or can verify that it should work?


For completeness here my code:
Code:
#include <i2c.c>

#define PIC_ADDR 0x0E

void blinkGreen(void)
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}

void blinkRed(void)
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}

void setup() {
   CDC.getKey();
//    I2C.init(I2C2, I2C_SLAVE_MODE, I2C_100KHZ);
   I2C_slave(I2C2,PIC_ADDR);
   I2C2ADD = PIC_ADDR;        //<---- seems to be ignored
   I2C2MSK = 0;
   pinMode(13, OUTPUT);
   pinMode(9, OUTPUT);
   digitalWrite(13, LOW);
   digitalWrite(9, LOW);
}

void loop() {
   if (I2C2STATbits.D_A) {
       u8 data;
       if (I2C2STATbits.RBF){
       data = I2C2RCV;        //<---- Produce the error
       blinkGreen();
       }
   }
   else blinkRed();

}
Reply
28-05-2015, 09:42 AM,
#16
RE: Accessing registers/interrupts
Issue 1:

Please edit sources/Makefile32.windows got to the compile: rule and delete line :

    $(CC) $(ELF_FLAGS) $(LDFLAGS) $(CFLAGS) $(MIPS16_OPT) -c -g -Wa,-a,-ad $(_IDE_SRCDIR_)\main32.c > $(_IDE_SRCDIR_)\main32.lst

Issue 2:

Do you get an error message or it just doesn't work ?
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
30-05-2015, 12:31 PM,
#17
RE: Accessing registers/interrupts
Thx, Regis. Unfortunately, issue 1 still exists after deleting the line you mentioned. Is there a possibilty to prevent the deleting of the temporary file ccspqKZc.s on my side? Then I could upload the file and maybe it shows what is going wrong.

Regarding issue 2 it is not an error message. I played it a bit around and found out, that the PIC prints the correct address when using

Code:
CDC.printf("Pic address: 0x%X \r\n", I2C2ADD);

But when I use i2cdetect on raspi side it shows me still 0x03 instead of 0x0E and the most confusing thing is, that the PIC is really responding on 0x03. Maybe raspi handels the address different, but why it should do that?
Reply
01-06-2015, 12:40 PM,
#18
RE: Accessing registers/interrupts
Please send me your program and will try to compile it on my computer.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
04-06-2015, 08:42 AM,
#19
RE: Accessing registers/interrupts
Here is the .pde, but it is just the code I posted above. If mean the code from raspi side, I attached it too.


Attached Files
.pde   raspi_to_pic_via_i2c.pde (Size: 1.4 KB / Downloads: 3)
.py   picontrol.py (Size: 135 bytes / Downloads: 0)
Reply
04-06-2015, 11:30 AM, (This post was last modified: 04-06-2015, 11:31 AM by regis.)
#20
RE: Accessing registers/interrupts
Here is what I get :

/usr/bin/../lib/gcc/mips-elf/4.9.2/../../../../mips-elf/bin/ld: region `kseg0_program_mem' overflowed by 628 bytes


The program is simply to big for your PIC32MX220 because the HID bootloader, the CDC library and the printf function are quite big.
You can't do anything about the bootloader but you could try to use Serial instead of CDC and print/printNumber instead of printf.
For example, if I replace :

CDC.printf("Pic address: 0x%X \r\n", I2C2ADD);


with :

CDC.print("Pic address: 0x");
CDC.printNumber(I2C2ADD, HEX);
CDC.print("\r\n");

I don't have any error anymore and the code size is 14268 / 16368 bytes (87% used).

If I now replace CDC with Serial then the code size is 9052 / 16368 bytes (55% used).

Last, if I compile the code with MIPS16 option, Serial and print/printNumber functions I get : 6792 / 16368 bytes (41% used).

Now you have 10K free Smile .
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)