Announcement

Collapse
No announcement yet.

Register injection not working PIC12F1572 and CODE not working

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Register injection not working PIC12F1572 and CODE not working

    I am working on RGB LED project and that's controlled by a PIC12F1572. The software that I am using is MPLAB IDE with the HiTech C compiler. The plan is to use serial communication to send LED RGB combination data commands to the PIC to be stored in a variable that will make it perform the LED blink and glowing I have been able to establish UART communication.Every function or step I code is right by syntax and works on linux command line terminal if I compile..
    And it fails if I try to simulate using register injection in MPLAB.I wanted to run it in simulation also (anyone knows how register injection actuallly works in MPLAB?)
    The problem I face together when I try to debug . it compiles but doesn't work
    here is my code :
    Any idea or hint about the problem will be highly appreciated.
    I personally fee that placing the code [hierarchical way] may be wrong
    Thanks!
    Code:
      
     #include<xc.h> #include"mcc.h" #include"LED.h" #include"tmr0.h" #include"interrupt_manager.h" voidSetLedColor(uint16_t R_color,uint16_t G_color,uint16_t B_color); void main(void) { uint8_t data ,i,j;  uint16_t R_value, G_value ,B_value; uint8_t value; uint8_t RX_Buffer[FRAMESIZE]={0}; uint8_t RGB_data[6],HEX_data[6];   // initialize the device  SYSTEM_Initialize();  INTERRUPT_GlobalInterruptEnable();// Enable the Global Interrupts  INTERRUPT_PeripheralInterruptEnable();// Enable the Peripheral Interrupts   while(1) { // EUSART_Write(0x61); while(!RCIF) {  data = EUSART_Read();// Read received character for(i =0; i<FRAMESIZE ; i++) {  RX_Buffer= data; }   EUSART_Write(data); }  //check if any data is received  for(j =0; j =5; j++)// get the RGB value in the separate array {  RGB_data[j]= RX_Buffer[j+3];  HEX_data[value]= RGB_data[j]/16; }  if(RX_Buffer[0]=='R'&& RX_Buffer[FRAMESIZE-1]=='\n') { //ASCII to HEX separate values  // uint32_t number = (uint32_t)strtol(HEX_data, NULL, 16); // R_value = number >>16; // G_value = (number & 0xffff) >> 8; // B_value = (number & 0x0000FF);   R_value =(uint16_t) atoh(HEX_data[0], HEX_data[1]);  G_value =(uint16_t) atoh(HEX_data[2], HEX_data[3]);  B_value =(uint16_t) atoh(HEX_data[4], HEX_data[5]);  }  SetLedColor(R_value,G_value,B_value); }    }

    Code:
      
     voidSetLedColor(uint16_t R_color,uint16_t G_color,uint16_t B_color) {   if(R_color ==0xFF) { LATAbits.LATA2 =1;  } else { LATAbits.LATA2 =0; }  if(G_color ==0xFF) {  LATAbits.LATA4 =1;  } else { LATAbits.LATA4 =0; } if(B_color ==0xFF) {  LATAbits.LATA5 =1; } else { LATAbits.LATA5 =0; }   }

Fresh & New Discussions

Collapse

Most Discussed

Collapse

What's Going On

Collapse

There are currently 146 users online. 8 members and 138 guests.

Most users ever online was 3,707 at 07:10 PM on September 4th, 2016.

Working...
X