Part Number: AM5728
Other Parts Discussed in Thread: SYSBIOS
Hello,
We have a requirement of toggling a gpio line with precise timing. For example, set a gpio high, wait for at least 9 microseconds but less than 11 microsecond, then set the gpio low.
We're running the code on ipu1 and there's nothing else running on that ipu. (There is code running on both dsp's and the main cpu)
I'm watching the output using a oscilloscope with 10 nanosecond resolution.
I see the output is low for as short as 6.12 microseconds and as long as 8.72 microseconds. This is outside the requirements.
We're using code based on ipc_3_47_02_00/examples/DRA7XX_linux_elf/ex02_messageq/ipu1/Server.c
I've stripped the gpio toggling code down to the basics (see below)
I'm using eCap free running timer (PWMSS_ECAP_TSCNT) for delay loops. Nothing other code on the system is using or accessing that register.
The performance of this code depends on the load on the main cpu, even with interrupts disabled. I would expect the timing to be basically independent of the rest of the system.
Is there something wrong with this code?
What can I check / change to achive reliable waveform timing? (The particular protocol isn't standard and isn't available in the chip)
Thank you,
Scott
Note: the register addresses start with "0x6" instead of the usual "0x4" because the code is running on the ipu.
volatile U32 * const PWMSS_ECAP_TSCNT = (U32 *) 0x68442100;
volatile U16 * const PWMSS_ECAP_ECCTL2 = (U16 *) 0x6844212A;
volatile U32 * const CTRL_CORE_PAD_GPMC_A5 = (U32 *) 0x6A003454;
volatile U32 * const CTRL_CORE_PAD_GPMC_A6 = (U32 *) 0x6A003458;
volatile U32 * const gpio1OE = (U32 *) 0x6AE10134;
volatile U32 * const gpio1Set = (U32 *) 0x6AE10194;
volatile U32 * const gpio1Clr = (U32 *) 0x6AE10190;
const U32 countusec = 128;
const int delay1 = 3 * countusec;
const int delay2 = 6 * countusec;
*PWMSS_ECAP_ECCTL2 = (1<<4); // set TSCNTSTP free running TSCNT
asm(" CPSID FI\n");
unsigned loop;
for ( loop = 0; loop < 16; ++loop )
{
*gpio1Clr = (1<<27); // clear gpio1_27
*PWMSS_ECAP_TSCNT = 0;
while ( *PWMSS_ECAP_TSCNT < delay1 )
{}
*gpio1Set = (1<<27); // set gpio1_27
*PWMSS_ECAP_TSCNT = 0;
while ( *PWMSS_ECAP_TSCNT < delay2 )
{}
}
asm(" CPSIE FI\n");




