|
[quote="PhillHS"]I have an AT91SAM7S-EK and am trying to use a group of 8 PIO lines as a bus to communicate with another micro, through a buffer.
[code] void Configure_BusPins(void) { PIO_Configure(&BusPinsOut,1); } [/code] In my main I make a call to Configure_BusPins() to configure the pins.[/quote]
Sorry for the late reply; you probably found out how to do things by now. I think you're missing some configuration, otherwise things look ok to me.
[quote]I have a timer that flashes the onboard LEDs periodically, and then calls WriteBusPins(bus_out++) to output the value to the pins and increment it.
However as soon as the first write takes place the LEDs stop updating. I temporaly put printf statements in WriteBusPins() and they seem to have the correct values being written from 0x00000000 to 0xFF000000, note the lower six digits are always 0 as expected.
Does anyone know what I am doing wrong ??[/quote]
You should probably consider the following, in (approximately) this order... [code]AT91F_PIO_Enable(...); AT91F_PIO_OutputEnable(...); AT91F_PIO_CfgPullup(...); AT91F_PIO_ClearOutput(...); AT91F_PIO_SetOutput(...);[/code]
...I will suggest, for your use, that you consider the following... [code]AT91F_PIO_CfgDirectDrive(...); /* this allow you to write the values _directly_ instead of using set/clear */[/code] ...you can then write the values using... [code]AT91F_PIO_ForceOutput(...);[/code]
...instead of using... [code]AT91F_PIO_SetOutput(...)[/code] ...and... [code]AT91F_PIO_ClearOutput(...)[/code] ...I believe, in your case, that would be much faster. The parameter for CfgDirectDrive is the bitmask that you will 'write at once'. All other bits are left unchanged, and can still be changed by AT91F_PIO_SetOutput/AT91F_PIO_ClearOutput. (same as AT91C_BASE_PIOA->PIO_CODR and AT91C_BASE_PIOA->PIO_SODR)
Your routine could then be reduced to the following: [code]void Write_BusPins(unsigned char ToWrite) { unsigned int WriteVal;
// Calculate value to actually write WriteVal=((unsigned int)ToWrite << BusShifts) & BusPins;
AT91C_BASE_PIOA->PIO_ODSR=WriteVal; } [/code]
|