Autor Tema: Llegó la hora: comienzo con ARM  (Leído 34483 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado skormel

  • PIC12
  • **
  • Mensajes: 50
    • Chaputronia
Re: Llegó la hora: comienzo con ARM
« Respuesta #90 en: 20 de Marzo de 2014, 20:51:16 »
Buaaaa vaya fallo tonto.

Muchas gracias por recordámelo.

Un saludo.

Desconectado skormel

  • PIC12
  • **
  • Mensajes: 50
    • Chaputronia
Re: Llegó la hora: comienzo con ARM
« Respuesta #91 en: 20 de Marzo de 2014, 22:44:09 »
El grader del Lab10 me tiene loco, no consigo pasar de 65 puntos. He mirado en el foro de piazza pero no consigo ver la solución. ¿Alguien sabe como se soluciona?

Código: [Seleccionar]
// ***** 0. Documentation Section *****
// TableTrafficLight.c for Lab 10
// Runs on LM4F120/TM4C123
// Index implementation of a Moore finite state machine to operate a traffic light.  
// Daniel Valvano, Jonathan Valvano
// November 7, 2013

// east/west red light connected to PB5
// east/west yellow light connected to PB4
// east/west green light connected to PB3
// north/south facing red light connected to PB2
// north/south facing yellow light connected to PB1
// north/south facing green light connected to PB0
// pedestrian detector connected to PE2 (1=pedestrian present)
// north/south car detector connected to PE1 (1=car present)
// east/west car detector connected to PE0 (1=car present)
// "walk" light connected to PF3 (built-in green LED)
// "don't walk" light connected to PF1 (built-in red LED)

// ***** 1. Pre-processor Directives Section *****
#include "TExaS.h"
#include "tm4c123gh6pm.h"

// ***** 2. Global Declarations Section *****

// FUNCTION PROTOTYPES: Each subroutine defined
void DisableInterrupts(void); // Disable interrupts
void EnableInterrupts(void);  // Enable interrupts
void PortF_Init(void); // Inicializar las luces de los peatones PF3 PF1
void PortB_Init(void); // Inicializar las luces de los semaforos PB[5-0]
void PortE_Init(void); // Inicializar los sensores PE[2-0]

// Initialize SysTick with busy wait running at bus clock.
void SysTick_Init(void);

// Time delay using busy wait.
// The delay parameter is in units of the core clock. (units of 12.5 nsec for 80 MHz clock)
void SysTick_Wait(unsigned long delay);

// Time delay using busy wait.
// This assumes 80 MHz system clock.
void SysTick_Wait10ms(unsigned long delay);

// ***** 3. Subroutines Section *****

// Linked data structure
struct State {
  unsigned long Out;
unsigned long OutPedest;
  unsigned long Time;  
  unsigned long Next[8];};
typedef const struct State STyp;

#define WaitAll 0
#define GoWest 1
#define GoWestWait 2
#define GoSouth 3
#define DoSouthWait 4
#define GoPedest 5
#define HurryUp1 6
#define HurryUp2 7
#define HurryUp3 8
#define HurryUp4 9
#define GoWestSouth 10
#define GoSouthWest 11
#define GoWestSouthPedest 12

STyp FSM[15] = {
{0x24,0x02,50,{0,1,3,2,5,1,3,1}},
{0x0c,0x02,100,{2,1,2,2,2,2,2,2}},
{0x14,0x02,50,{0,0,0,10,5,5,3,3}},
{0x21,0x02,100,{4,4,3,4,4,4,4,4}},
{0x22,0x02,50,{0,0,0,11,5,5,5,12}},
{0x24,0x08,100,{6,6,6,6,5,6,6,6}},
{0x24,0x02,50,{7,7,7,7,7,7,7,7}},
{0x24,0x08,50,{8,8,8,8,8,8,8,8}},
{0x24,0x02,50,{9,9,9,9,9,9,9,9}},
{0x24,0x08,50,{13,13,13,13,13,13,13,13}},
{0x24,0x02,25,{0,1,3,3,5,5,3,3}},
{0x24,0x02,25,{0,1,3,1,5,5,1,5}},
{0x24,0x02,25,{0,1,3,1,5,5,5,5}},
  {0x24,0x02,50,{14,14,14,14,14,14,14,14}},
{0x24,0x08,50,{0,0,0,0,0,0,0,0}}
};

unsigned char cState;      // current State (0 to 14)
unsigned char input;

int main(void){
  TExaS_Init(SW_PIN_PE210, LED_PIN_PB543210); // activate grader and set system clock to 80 MHz

PortF_Init();
PortE_Init();
PortB_Init();
SysTick_Init();
cState = 0;
  
  EnableInterrupts();
  while(1){
GPIO_PORTB_DATA_R = FSM[cState].Out;
GPIO_PORTF_DATA_R = FSM[cState].OutPedest;

SysTick_Wait10ms(FSM[cState].Time);

input = GPIO_PORTE_DATA_R&0x07;  // Enmascaramos el resto de entradas que no sean PE[2-0]

cState = FSM[cState].Next[input];
  }
}

void PortF_Init(void){ volatile unsigned long delay;
  SYSCTL_RCGC2_R |= 0x00000020;     // 1) activate clock for Port F
  delay = SYSCTL_RCGC2_R;           // allow time for clock to start
  GPIO_PORTF_AMSEL_R = 0x00;        // 2) disable analog on PF
  GPIO_PORTF_PCTL_R = 0x00000000;   // 3) PCTL GPIO on PF4-0
  GPIO_PORTF_DIR_R |= 0x0A;        // 4) PB[0-5] is out
  GPIO_PORTF_AFSEL_R &= ~0x0A;      // 5) disable alt funct on PF7-0
  GPIO_PORTF_PUR_R |= 0x0A;         // enable pull-up on PF4
  GPIO_PORTF_DEN_R |= 0x0A;         // 6) enable digital I/O on PF4
}

void PortE_Init(void){ volatile unsigned long delay;
  SYSCTL_RCGC2_R |= 0x00000010;     // 1) activate clock for Port F
  delay = SYSCTL_RCGC2_R;           // allow time for clock to start
  GPIO_PORTE_AMSEL_R = 0x00;        // 2) disable analog on PE
  GPIO_PORTE_PCTL_R = 0x00000000;   // 3) PCTL GPIO on PE2-0
  GPIO_PORTE_DIR_R &= ~0x07;        // 4) PE[2-0] in
  GPIO_PORTE_AFSEL_R &= ~0x07;      // 5) disable alt funct on PE7-0
  GPIO_PORTE_PUR_R |= 0x07;         // enable pull-up on PE[2-0]
  GPIO_PORTE_DEN_R |= 0x07;         // 6) enable digital I/O on PE[2-0]
}

void PortB_Init(void){ volatile unsigned long delay;
  SYSCTL_RCGC2_R |= 0x00000002;     // 1) activate clock for Port B
  delay = SYSCTL_RCGC2_R;           // allow time for clock to start
  GPIO_PORTB_AMSEL_R = 0x00;        // 3) disable analog on PB
  GPIO_PORTB_PCTL_R = 0x00000000;   // 4) PCTL GPIO on PB0
  GPIO_PORTB_DIR_R |= 0x3F;         // 5) PB[0-5] is out
  GPIO_PORTB_AFSEL_R &= ~0x3F;      // 6) disable alt funct on PB0
  GPIO_PORTB_DEN_R |= 0x3F;         // 7) enable digital I/O on PB0
}

void SysTick_Init(void){
  NVIC_ST_CTRL_R = 0;               // disable SysTick during setup
  NVIC_ST_CTRL_R = 0x00000005;      // enable SysTick with core clock
}
// The delay parameter is in units of the 80 MHz core clock. (12.5 ns)
void SysTick_Wait(unsigned long delay){
  NVIC_ST_RELOAD_R = delay-1;  // number of counts to wait
  NVIC_ST_CURRENT_R = 0;       // any value written to CURRENT clears
  while((NVIC_ST_CTRL_R&0x00010000)==0){ // wait for count flag
  }
}
// 10000us equals 10ms
void SysTick_Wait10ms(unsigned long delay){
  unsigned long i;
  for(i=0; i<delay; i++){
    SysTick_Wait(800000);  // wait 10ms
  }
}

Y esta es la salida
Código: [Seleccionar]
Running with Code Size Limit: 32K
Load "C:\\Keil4\\Labware\\Lab10_TrafficLight\\Lab10.axf"

*** Restricted Version with 32768 Byte Code Size Limit
*** Currently used: 19052 Bytes (58%)

Start grading
Clock rate appears to be : 80 MHz
Running 5 tests

0) Initialization tests :

 - (PE2-0) have been selected as the input pins
 - Verifying input configuration...
   Pass: PORTE DEN bits (2-0) are high
   Pass: PORTE DIR bits (2-0) are low
   Pass: PORTE AFSEL bits (2-0) are low
   Pass: PORTE AMSEL bits (2-0) are low
   Pass: PORTE PCTL bits (11-0) are low

 - (PB5-0) have been selected as the output pins
 - Verifying output configuration...
   Pass: PORTB DEN bits (5-0) are high
   Pass: PORTB DIR bits (5-0) are high
   Pass: PORTB AFSEL bits (5-0) are low
   Pass: PORTB AMSEL bits (5-0) are low
   Pass: PORTB PCTL bits (23-0) are low

1) Servicing all 3 requests, lights should make a complete cycle
   FSM: Transition: 1 to 2
   FSM: Transition: 2 to 3
   FSM: Transition: 3 to 4
   FSM: Transition: 4 to 5
   FSM: Transition: 5 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 2
   FSM: Transition: 2 to 3
   FSM: Transition: 3 to 4
   FSM: Transition: 4 to 5
   FSM: Transition: 5 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 2
   FSM: Transition: 2 to 3
   FSM: Transition: 3 to 4
   FSM: Transition: 4 to 5
   FSM: Transition: 5 to 1
   FSM: Transition: 1 to 6
 * FAIL: Did not service all requests before the timeout
   Pass: South request was serviced
   Pass: West request was serviced
 * FAIL: Walk request was not serviced
 - Test FAILED

2) Servicing walk button, walk light should come on
   Pass: All requests were serviced
   Pass: Walk request was serviced
 - Test PASSED

3) Servicing west button, west green light should come on
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 2
   Pass: All requests were serviced
   Pass: West request was serviced
 - Test PASSED

4) Servicing south button, south green light should come on
   FSM: Transition: 2 to 3
   FSM: Transition: 3 to 1
   FSM: Transition: 1 to 4
   Pass: All requests were serviced
   Pass: South request was serviced
 - Test PASSED

Done grading. Score is 65

Muchas gracias.

Un saludo.

Desconectado Nocturno

  • Administrador
  • DsPIC33
  • *******
  • Mensajes: 18310
    • MicroPIC
Re: Llegó la hora: comienzo con ARM
« Respuesta #92 en: 21 de Marzo de 2014, 03:08:23 »
NO veo dónde tienes el fallo, pero si quieres te paso mi código

Desconectado skormel

  • PIC12
  • **
  • Mensajes: 50
    • Chaputronia
Re: Llegó la hora: comienzo con ARM
« Respuesta #93 en: 21 de Marzo de 2014, 05:03:30 »
NO veo dónde tienes el fallo, pero si quieres te paso mi código

Pues mira la verdad es que me sería de gran ayuda, ya que en el modo manual funciona todo a la perfección. Según he visto hay un montón de gente en el foro del curso que le pasa lo mismo (es una peculiaridad del grader 10 de los coj....)

Un saludo.

Desconectado fuente

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 573
Re: Llegó la hora: comienzo con ARM
« Respuesta #94 en: 21 de Marzo de 2014, 05:11:53 »
Una semana... Una semana enterita me he estado devanando los sesos con el %&$·$·$% de la máquina de elementos finitos, para que al final haya sido culpa del grader.
Publicaron una versión el 2 de marzo que no había visto. Ayer me di cuenta, la instalé y funcionó con la primera versión que hice.



Desconectado skormel

  • PIC12
  • **
  • Mensajes: 50
    • Chaputronia
Re: Llegó la hora: comienzo con ARM
« Respuesta #95 en: 21 de Marzo de 2014, 05:17:21 »
Una semana... Una semana enterita me he estado devanando los sesos con el %&$·$·$% de la máquina de elementos finitos, para que al final haya sido culpa del grader.
Publicaron una versión el 2 de marzo que no había visto. Ayer me di cuenta, la instalé y funcionó con la primera versión que hice.

Me he bajado este Enlace pero sigue igual. Esta grader es un poco toca bola, anoche leí que había gente que cambiando el estado inicial de la máquina le funcionaba (algo que debería ser irrelevante).

Desconectado skormel

  • PIC12
  • **
  • Mensajes: 50
    • Chaputronia
Re: Llegó la hora: comienzo con ARM
« Respuesta #96 en: 21 de Marzo de 2014, 15:12:03 »
Tras probar el código de nocturno, obtengo el mismo resultado, 65%. Sin embargo nocturno me asegura que con ese código ha obtenido el 100% tanto en simulación como en real. ¿qué diablos pasará? He instalado el update del grader varias veces y no parece solucionar el fallo.

Esta es la salida:
Código: [Seleccionar]
Running with Code Size Limit: 32K
Load "C:\\Keil4\\Labware\\Lab10_TrafficLight\\Lab10.axf"

*** Restricted Version with 32768 Byte Code Size Limit
*** Currently used: 18948 Bytes (57%)

LA ((PORTB & 0x01) & 0x1) >> 0
LA ((PORTB & 0x02) >> 1 & 0x2) >> 1
LA ((PORTB & 0x04) >> 2 & 0x4) >> 2
LA ((PORTB & 0x08) >> 3 & 0x8) >> 3
LA ((PORTB &0x10) >> 4 & 0x10) >> 4
LA ((PORTB & 0x20) >> 5 & 0x20) >> 5
LA ((PORTF & 0x02) >> 1 & 0x2) >> 1
LA ((PORTF & 0x08) >> 3 & 0x8) >> 3
Start grading
Clock rate appears to be : 80 MHz
Running 5 tests

0) Initialization tests :

 - (PE2-0) have been selected as the input pins
 - Verifying input configuration...
   Pass: PORTE DEN bits (2-0) are high
   Pass: PORTE DIR bits (2-0) are low
   Pass: PORTE AFSEL bits (2-0) are low
   Pass: PORTE AMSEL bits (2-0) are low
   Pass: PORTE PCTL bits (11-0) are low

 - (PB5-0) have been selected as the output pins
 - Verifying output configuration...
   Pass: PORTB DEN bits (5-0) are high
   Pass: PORTB DIR bits (5-0) are high
   Pass: PORTB AFSEL bits (5-0) are low
   Pass: PORTB AMSEL bits (5-0) are low
   Pass: PORTB PCTL bits (23-0) are low

1) Servicing all 3 requests, lights should make a complete cycle
   FSM: Transition: 1 to 4
   FSM: Transition: 4 to 5
   FSM: Transition: 5 to 1
   FSM: Transition: 1 to 6
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 7
   FSM: Transition: 7 to 1
   FSM: Transition: 1 to 7
 * FAIL: Did not service all requests before the timeout
 * FAIL: South request was not serviced
   Pass: West request was serviced
   Pass: Walk request was serviced
 - Test FAILED

2) Servicing walk button, walk light should come on
   FSM: Transition: 7 to 1
   FSM: Transition: 1 to 6
   Pass: All requests were serviced
   Pass: Walk request was serviced
 - Test PASSED

3) Servicing west button, west green light should come on
   FSM: Transition: 6 to 1
   FSM: Transition: 1 to 7
   FSM: Transition: 7 to 1
   FSM: Transition: 1 to 7
   FSM: Transition: 7 to 1
   FSM: Transition: 1 to 2
   Pass: All requests were serviced
   Pass: West request was serviced
 - Test PASSED

4) Servicing south button, south green light should come on
   FSM: Transition: 2 to 3
   FSM: Transition: 3 to 4
   Pass: All requests were serviced
   Pass: South request was serviced
 - Test PASSED

Done grading. Score is 65

Esta semana tendré un 0 en lab y yastá, no me voy a comer más la cabeza.

Muchísimas gracias a todos por la ayuda.

Un saludo.

Desconectado Nocturno

  • Administrador
  • DsPIC33
  • *******
  • Mensajes: 18310
    • MicroPIC
Re: Llegó la hora: comienzo con ARM
« Respuesta #97 en: 21 de Marzo de 2014, 15:21:23 »
Qué raro. No me atrevo a probarlo a ver si me va a rebajar la graduación, pero cuando lo hice funcionó perfecto.

Desconectado fuente

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 573
Re: Llegó la hora: comienzo con ARM
« Respuesta #98 en: 21 de Marzo de 2014, 16:28:00 »
Se puede ejecutar el grade sin meter el código, no pierdes nada.
No estoy en casa, mañana te envío el mío para que lo pruebes a ver.

Desconectado Nocturno

  • Administrador
  • DsPIC33
  • *******
  • Mensajes: 18310
    • MicroPIC
Re: Llegó la hora: comienzo con ARM
« Respuesta #99 en: 22 de Marzo de 2014, 02:36:43 »
¡Tienes razón, ni lo pensé!  :lol: :lol:

Efectivamente, al ejecutar el grader con el código que te he enviado, Skormel, no graduaba bien, pero lo he resuelto.

Recordé que después de hacer la práctica simulada, subí los retardos para que en la práctica real los tiempos fueran más normales, pero con estos tiempos el simulador daba Timeout.

Cambia los retardos de 250 a 5 en la tabla de estados y te funcionará 100%.

Código: [Seleccionar]
#define RETARDO 5

tEstado FSM[11]={
 {sTodoRojo, RETARDO, {TodoRojo, OVerde, SVerde, OVerde, WVerde, WVerde, WVerde, SVerde }},
 {sOVerde, RETARDO, {OAmarillo, OVerde, OAmarillo, OAmarillo, OAmarillo, OAmarillo, OAmarillo, OAmarillo }},
 {sOAmarillo, RETARDO, {TodoRojo, TodoRojo, SVerde, SVerde, WVerde, WVerde, WVerde, SVerde }},
 {sSVerde, RETARDO, {SAmarillo, SAmarillo, SVerde, SAmarillo, SAmarillo, SAmarillo, SAmarillo, SAmarillo }},
 {sSAmarillo, RETARDO, {TodoRojo, OVerde, TodoRojo, OVerde, WVerde, WVerde, WVerde, WVerde }},
 {sWVerde, RETARDO, {DWflash1, DWflash1, DWflash1, DWflash1, WVerde, DWflash1, DWflash1, DWflash1 }},
 {sDWflash1, RETARDO, {DWflash2, DWflash2, DWflash2, DWflash2, DWflash2, DWflash2, DWflash2, DWflash2 }},
 {sDWflash2, RETARDO, {DWflash3, DWflash3, DWflash3, DWflash3, DWflash3, DWflash3, DWflash3, DWflash3 }},
 {sDWflash3, RETARDO, {DWflash4, DWflash4, DWflash4, DWflash4, DWflash4, DWflash4, DWflash4, DWflash4 }},
 {sDWflash4, RETARDO, {DWflash5, DWflash5, DWflash5, DWflash5, DWflash5, DWflash5, DWflash5, DWflash5 }}, 
 {sDWflash5, RETARDO, {TodoRojo, OVerde, SVerde, OVerde, WVerde, WVerde, WVerde, OVerde }},
};

Desconectado skormel

  • PIC12
  • **
  • Mensajes: 50
    • Chaputronia
Re: Llegó la hora: comienzo con ARM
« Respuesta #100 en: 22 de Marzo de 2014, 14:08:44 »
Este último diagrama de estado si ha funcionado.

Muchas gracias.

Desconectado Nocturno

  • Administrador
  • DsPIC33
  • *******
  • Mensajes: 18310
    • MicroPIC
Re: Llegó la hora: comienzo con ARM
« Respuesta #101 en: 26 de Mayo de 2014, 15:19:16 »
Bueno, ya terminó el curso. Ha sido muy interesante; no profundiza en las entrañas del ARM pero sí te pone en la senda para que sigas investigando.

Y además, ¡ya tengo mi certificado!

Desconectado fuente

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 573
Re: Llegó la hora: comienzo con ARM
« Respuesta #102 en: 29 de Mayo de 2014, 11:09:45 »
También lo conseguí, aunque lo he hecho muy por encima.
No tuve tiempo de meterme con la última parte del videojuego, pero no ha estado del todo mal.

Desconectado elmasvital

  • Administrador
  • PIC24H
  • *******
  • Mensajes: 1713
Re: Llegó la hora: comienzo con ARM
« Respuesta #103 en: 13 de Julio de 2014, 12:09:59 »
Buenas... uno más que se apunta al LaunchPad.

Estoy usando la plataforma CCS de Ti que está basada en eclipse y la verdad el cambio ha sido brutal. Me pasa igual que cuando vi C18 o C30 de microchip. Ves un programa y parece que no está hecho en C.

Un saludito a todos los antiguos que hace mucho que no me pasaba por aqui.


Desconectado Nocturno

  • Administrador
  • DsPIC33
  • *******
  • Mensajes: 18310
    • MicroPIC
Re: Llegó la hora: comienzo con ARM
« Respuesta #104 en: 14 de Julio de 2014, 15:31:37 »
¡Hombre, cuánto tiempo!, bienvenido de vuelta.