Bit banging I2C and SPI Codes are same for any microcontroller. They bit banging code from saeedsolution.blogspot.com Modify the codes to LPCxxxx code else post LPCxxxx code I will try to add the bit banging code for it.
The OP is referring to Bit Ban
ding, not Bit Ban
ging.
There is a considerable difference between the two.
@lgeorge123
Bit Banding is typically handled by compiler and command line directives, therefore its implementation and utilization is not only highly device dependent it is also highly compiler dependent.
If you are using the KEIL C Compiler, the following maybe of interest:
Reference: **broken link removed**
Reference: **broken link removed**
Using the --bitband command-line option
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| /* foo.c */
typedef struct {
int i : 1;
int j : 2;
int k : 3;
} BB;
BB value __attribute__((at(0x20000040))); // Placed object
void update_value(void)
{
value.i = 1;
value.j = 0;
}
/* end of foo.c */ |
Bit-banding of objects accessed through absolute addresses
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| /* foo.c */
typedef struct {
int rts : 1;
int cts : 1;
unsigned int data;
} uart;
#define com2 (*((volatile uart *)0x20002000))
void put_com2(int n)
{
com2.rts = 1;
com2.data = n;
}
/* end of foo.c */ |
Reference: **broken link removed**
Unplaced object
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| /* foo.c */
typedef struct {
int i : 1;
int j : 2;
int k : 3;
} BB __attribute__((bitband));
BB value; // Unplaced object
void update_value(void)
{
value.i = 1;
value.j = 0;
}
/* end of foo.c */ |
Placed object
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| /* foo.c */
typedef struct {
int i : 1;
int j : 2;
int k : 3;
} BB __attribute((bitband));
BB value __attribute__((at(0x20000040))); // Placed object
void update_value(void)
{
value.i = 1;
value.j = 0;
}
/* end of foo.c */ |
BigDog