VS1010 Create PWM with GPIO1_7 for Fading LED effect on Startup

Designing hardware and software for systems that use the VS1010 MP3 Audio DSP Microcontroller.
Post Reply
Burnzie
User
Posts: 1
Joined: Tue 2022-05-24 13:59

VS1010 Create PWM with GPIO1_7 for Fading LED effect on Startup

Post by Burnzie »

Hi,
I got the VS1010D LQFP-48 and im using the VSIDE IDE (TreePlayer).

I want to create a fading effect (dark to bright) for my LED on Pin XCS1/GPIO1_7 ONLY on Startup-Sequence.

This Pin is not the PWM-Pin (PWM/DLK/GPIO0_0)
The primary funtion of this Pin is "SPI1 CLK" but that is not used.

Can somebody help me to find a way to get a Software PWM Signal out of that Pin?
Do i need to use a Timer?

I would be really thankful if somebody can Help me.
User avatar
pasi
VLSI Staff
Posts: 1984
Joined: Thu 2010-07-15 16:04

Re: VS1010 Create PWM with GPIO1_7 for Fading LED effect on Startup

Post by pasi »

You can try the below "advanced pulse density modulation" version I made a few weeks back. I modified it to use GPIO1, that part is untested.

Code: Select all

void DeClickIO1(register __c0 s_int16 start, register __c1 s_int16 speed, register __d0 s_int16 bitNum);
Call DeClickIO1(0x7fff, -16, 7); to fade GPIO1_7 from 1 to 0 with speed -16.
Call DeClickIO1(0, 16, 7); to fade GPIO1_7 from 0 to 1 with speed -16.
GPIO1_7 needs to be in GPIO mode and configured as output before the call.

The result is smooth if there are no interrupts. The speed depends on the clock multiplier (normally 5.0x for vs1010) and the speed parameter. The start value and the sign of the speed parameter must match.

declickasm.s:

Code: Select all

#include <vs1005g.h>
//void DeClickIO1(register __c0 s_int16 start, register __c1 s_int16 speed,
//       register __d0 s_int16 bitNum);

	.sect data_y,init_y //pwm_seed
_pwm2_seed:
	.word 0

	.sect code,DeClickIO1
	.export _DeClickIO1
_DeClickIO1:
	ldx (i6)+1,null
	stx a0,(i6)+1	; sty a1,(i6)
	stx lc,(i6)+1	; sty ls,(i6)
	stx le,(i6)+1	; sty b0,(i6)

	//DeClickPwm doesn't destroy c0, so use it as loop var
	ldc _pwm2_seed,i7
	sub null,ones,b0	; stx b1,(i6)	; ldy (i7),a0
	ldc GPIO1_BIT_CONF,i5
	ldc (15<<4)/*|(8<<0)*/,b1 //ENG0: Route data bit 15 to GPIO0_X
	or b1,d0,b1		  //ENG0: Route data bit 15 to GPIO0_X
	ashl b0,d0,d0	; sty b1,(i5)+(GPIO1_BIT_ENG0-GPIO1_BIT_CONF) //1<<bit

	ldc 16217,b1
	ldc 9043,b0	//0x951,b0
$0:	ldc 0x3fff,ls
	loop ls,$10-1
	mulss a0,b1

$11:	add b,p,a	// x(n+1) = (a*x(n)+c) mod m
	lsr a0,a1	// output: 0..0x7fff
	add a1,c0,a1	// Add the PWM ratio
	mulss a0,b1	; sty a1,(i5) //GPIO1_BIT_ENG0 bit 15 to GPIO1_X
	//9->4 cycles!
$10:
	add c0,c1,c0	; sty a0,(i7)
	ldc 0x3fff,lc	//ls and le already correct
	jnc $11
	add c1,null,c1

	nop		//ldc (1<<8),a0 //pwm bit is parameter now
	jns $1	
	ldc GPIO1_CLEAR_MASK,i5
	ldc GPIO1_SET_MASK,i5
$1:	ldx (i6)-1,b1		; sty d0,(i5)
	ldx (i6)-1,le	; ldy (i6),b0
	ldx (i6)-1,lc	; ldy (i6),ls
	jr
	ldx (i6)-1,a0	; ldy (i6),a1

	.end

Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Post Reply