IIC example
Chris Gransden (337) 1207 posts |
There doesn’t seem to be too many working examples in C accessing IIC devices from RISC OS.
|
Rick Murray (539) 13850 posts |
Well, if it works then there’s nothing to worry about. ;-) OMG, that’s dirt cheap. Can RISC OS use the RTC and/or NVRAM? |
Chris Gransden (337) 1207 posts |
The RTC gets used automatically by RISC OS. Not looked at the NVRAM. I think there’s only 32 bytes. |
Lothar (3292) 134 posts |
> The RTC gets used automatically by RISC OS In RPCEmu, direct also works. For real RTC connected to a Pi – should work similar: unsigned char buffer[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; int cnt = 0; while (1) { // RTC PCF8583 address 0x50 + write : register address 0x00 buffer[0] = 0x00; IIC_Control((0x50 << 1) + 0, (int) buffer, 1); // RTC PCF8583 address 0x50 + read : 8 bytes auto-increment IIC_Control((0x50 << 1) + 1, (int) buffer, 8); printf("%d\n", cnt); printf("status = 0x%02x\n", buffer[0]); printf("centisec = 0x%02x\n", buffer[1]); printf("sec = 0x%02x\n", buffer[2]); printf("min = 0x%02x\n", buffer[3]); printf("hour = 0x%02x\n", buffer[4]); printf("year = 0x%02x\n", buffer[5]); printf("month = 0x%02x\n", buffer[6]); printf("timer = 0x%02x\n", buffer[7]); printf("\n"); cnt++; delay(50); } |
Stefano Bertinetti (2512) 21 posts |
If the NVRAM device is a 24C32 as shown in the photo, it’s a 4k*8 serial EEPROM. |
Steve Pampling (1551) 8172 posts |
I think the 24C32 is an obsolete device, the replacement is the 24LC32A. 1 Which, having risen in price over the years (up with potato prices and never back down with them) aren’t actually that cheap. No, chips are NOT “fries”2, which are a mistake on many levels. 2 Chips are prepared, in raw state, by thick cutting potatoes into fingers. These are then fried. Since the even cutting is usually referred to as “Frenching” you can see where the merkin tag of “French fries” derives. This as with much else has come back from across the pond in its distorted form, and we now have potato twiglets masquerading as ‘chips’ BTW. For those mistaken souls ‘chips’ are not wafer thin potato slices. |
Chris Evans (457) 1614 posts |
They still can be had! Octopart is your friend.
Some parts we buy have prices in pence with two or three decimal places. They expect people to be ordering in 100’s or more using rounding if necessary. |
Steve Pampling (1551) 8172 posts |
Two things:
When you buy in 100’s it’s a different fraction… |