"GpioReadPin" works well, added "GpioSetPin" make reset

Designing hardware and software for systems that use the VS1010 MP3 Audio DSP Microcontroller.
Post Reply
Arek
Senior User
Posts: 34
Joined: Thu 2016-09-01 10:58

"GpioReadPin" works well, added "GpioSetPin" make reset

Post by Arek » Fri 2018-04-27 13:27

Hello,

I have a problem with setting pins.
Check inputs with "GpioReadPin" works fine.
Added/uncommented "GpioSetPin" (see "case 1" and "case 3") make neverending loop with resets.


Program:

Code: Select all

#include <vo_stdio.h>
#include <volink.h>    // Linker directives like DLLENTRY
#include <apploader.h> // RunLibraryFunction etc
#include <timers.h>
#include <vs1010cRom.h>
#include <vo_gpio.h>
#include <vs1010b.h>
#include <playerinfo.h>
#include <string.h>
#include <protocol.h>
#include <stdlib.h>

#define PS0 GpioReadPin(0x20)
#define PS1 GpioReadPin(0x21)
#define PS2 GpioReadPin(0x22)


u_int16 StageNr_Old;
u_int16 StageNr;


/***********************************************/
ioresult main (char *params) 
{
	StageNr_Old = 10;
	printf("AMP3 START\n");

	while(1)
	{
		StageNr = 0;

		DelayL(10000000);

		if (!GpioReadPin(0x20)){ StageNr = 1;}
		if (!GpioReadPin(0x21)){ StageNr = StageNr + 2;}
		if (!GpioReadPin(0x22)){ StageNr = StageNr + 4;}
	
		if (StageNr != StageNr_Old)
		{
			switch(StageNr)
			{
				case 0:
					printf("StageNr = 0\n");
					break;
		
				case 1:
				{
					printf("StageNr = 1\n");

					GpioSetPin(0x26, 1);
					GpioSetPin(0x27, 0);

					break;
				}

				case 2:
					printf("StageNr = 2\n");
					break;
		
				case 3:
					printf("StageNr = 3\n");
					GpioSetPin(0x26, 0);
					GpioSetPin(0x27, 1);

					break;
		
				case 4:
					printf("StageNr = 4\n");
					break;
		
				case 5:
					printf("StageNr = 5\n");
					break;
		
				case 6:
					printf("StageNr = 6\n");
					break;
		
				case 7:
					printf("StageNr = 7\n");
					break;
			} // switch

		StageNr_Old = StageNr;	
		printf("Ende \n");

		} // if (StageNr != StageNr_Old)

	} // while(1)

	return S_OK;
}

The loop:

Code: Select all

C#0d1d
VS1010C VSOS 4.02
Files:6. Buffers:3.
Runlevel 7
SPIF:c214, 2048K

SD:No ID.Patch v10

Hello. Runlevel 7
AMP3 START
StageNr = 1

C#0d1d
VS1010C VSOS 4.02
Files:6. Buffers:3.
Runlevel 7
SPIF:c214, 2048K

SD:No ID.Patch v10

Hello. Runlevel 7
AMP3 START
StageNr = 1

C#0d1d
VS1010C VSOS 4.02
Files:6. Buffers:3.
Runlevel 7
SPIF:c214, 2048K

SD:No ID.Patch v10

Hello. Runlevel 7
AMP3 START

StageNr = 1

C#0d1d
VS1010C VSOS 4.02
Files:6. Buffers:3.
Runlevel 7
SPIF:c214, 2048K

SD:No ID.Patch v10

Perhaps I overseen something. But what???


Another question.
I get trouble to play mp3 files. Q: Works "PlayerPlayFile" (modified Demo10) with spi memory?

And last point (today:)
in "C:\VLSI\VSIDE\libvs1010" a header file "vs1010cRom.h" started wirh "#ifndef VS1010BROM_H...". I think should be "C" and not "B".


Many thanks and best regards
AM

Arek
Senior User
Posts: 34
Joined: Thu 2016-09-01 10:58

Re: "GpioReadPin" works well, added "GpioSetPin" make reset

Post by Arek » Mon 2018-04-30 16:00

Update:

writting
PERIP(GPIO2_DDR) = 0x3080;
PERIP(GPIO2_ODATA) = 0x3080;


instead of
GpioSetPin(0x27, 1);

works well.

User avatar
pasi
VLSI Staff
Posts: 1479
Joined: Thu 2010-07-15 16:04

Re: "GpioReadPin" works well, added "GpioSetPin" make reset

Post by pasi » Thu 2018-05-03 11:18

I don't know what the issue with GpioSetPin() is (possibly the macro/prototype is wrong).

You probably should not write explicit values but set and clear only the bits you want. i.e.
PERIP(GPIO2_DDR) |= (1<<7);
PERIP(GPIO2_SET_MASK) = (1<<7);
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Arek
Senior User
Posts: 34
Joined: Thu 2016-09-01 10:58

Re: "GpioReadPin" works well, added "GpioSetPin" make reset

Post by Arek » Thu 2018-05-03 16:54

Pasi, thank you.
Yes, writing the whole register was test only.

Update to my first mesage:
Playing from serial memory works!

Post Reply