Jump to content

pbraju123

EstablishedMember
  • Content Count

    26
  • Joined

  • Last visited

Community Reputation

0 Neutral

About pbraju123

  • Rank
    Regular
  1. I assume you are waiting long enoought for the count to ripple through the prescalar. If so then instead of using the logical names use the addresses and specific bits of the registers to make sure there is no fault with the header file. <{POST_SNAPBACK}> I have changed the program like this uchar Timer1con@0x0FCD; uchar Tmr1H_reg@0x0FCF; uchar Tmr1L_reg@0x0FCE; void ConfigureTimer1(void) //using timer1 { Timer1con = 0xB0; Tmr1H_reg = 0xFF; Tmr1L_reg = 203; clear_bit(pir1,TMR1IF); set_bit(Timer1con,0); } I hope thats what you intended. but got no improvement. the simulator shows all the T1CON values cofigured as well as tmr1h and tmr1l values in both the cases. but in all cases tmr1h and tmr1l does not increment.
  2. no effect on the tmr1h/tmr1l registers.will the simulator not show the updated values? Its strange I had worked on timers previously but never faced such difficulty. Has anyone used this timer?
  3. A couple of things. You have configured the timer to use the external timer 1 ocsillator input. Was this your intention or were you planning on using the PICs instruction clock? You have configured the timer for 16 bit operation. This uses a latch for reading and writing the THR1H register. In this mode you MUST write the TMR1H value before the TMR1L value. Similarly, when reading the contents you MUST read the TMR1L before reading the TMR1H. <{POST_SNAPBACK}> sorry a little correction, I want to run it on internal clock, I have tested this also: void ConfigureTimer1(void) //using timer1 { set_bit(pie1,TMR1IE); t1con = 0xB0; //changed tmr1l = 203; tmr1h = 0xFF; clear_bit(pir1,0); //tmr1if set_bit(intcon,GIEH); set_bit(intcon,GIEL); set_bit(intcon,PEIE); set_bit(t1con,TMR1ON); } I have interchanged the lines tmr1h = 0xFF; tmr1l = 203; is that what needed? but I still do not find it incrementing in the simulator. is it that it does not get updated in the simulator? please guide>
  4. I know a very little about SPI access, which I feel should share with you. please point out if I am wrong. actually , when you read from SPI device(I used SPI E2PROM) the device will not generate clock to send data. the micro-controller (master) will have to simulate the clock line and data will be clocked in the sspbuf. now to simulate the clock I have sent dummy data(0x00). this transmits dummy data as well as simulates the clock to get the data from the chip. please read the routine which works, may not be appropriate for you, but you will get some clues at least. /***************************** read routine start *************************/ void SPI_Read(unsigned char No_Of_Bytes) { unsigned char i = 0,l; Test_Buffer = 0; fsr = 0x38; CS = 0xFF; trisc = 0x10; asm { nop } Send_Command(Write_Disable); //WRDI 0x04 CS = 0xFF; asm { nop } Send_Command(Read_Memory_Array); //READ 0x03 asm { nop nop nop nop } sspbuf = 0x02; //Hi address asm { nop nop nop nop nop nop nop } sspbuf = 0x10; //Lo_Address; asm { nop nop nop nop nop nop } while(i < No_Of_Bytes) { trisc = 0x30; //C.5 - input,C.4 - input sspbuf = 0x00; asm { nop nop nop nop nop } while(!(sspstat & 0x01)) { ; } indf = sspbuf ; fsr++; i++; } CS = 0xFF; trisc = 0x10; } /***************************** read routine over *************************/ Hope this will be of some help. Regards, P B Raju
  5. I have used the following configuration for operating the Timer1 of PIC18F458 void ConfigureTimer1(void) //using timer1 { set_bit(pie1,TMR1IE); t1con = 0xB4; tmr1l = 203; tmr1h = 0xFF; clear_bit(pir1,0); //tmr1if set_bit(intcon,GIEH); set_bit(intcon,GIEL); set_bit(intcon,PEIE); set_bit(t1con,TMR1ON); } Have I gone wrong somewhere in configuring the interrupt? or is there any problem with the sequence? I don't see the increment in the Tmrl/h registers while I run the program in the simulator. Regards P B Raju
  6. I have used the following configuration for operating the Timer1 of PIC18F458 void ConfigureTimer1(void) //using timer1 { set_bit(pie1,TMR1IE); t1con = 0xB4; tmr1l = 203; tmr1h = 0xFF; clear_bit(pir1,0); //tmr1if set_bit(intcon,GIEH); set_bit(intcon,GIEL); set_bit(intcon,PEIE); set_bit(t1con,TMR1ON); } Have I gone wrong somewhere in configuring the interrupt? or is there any problem with the sequence? I don't see the increment in the Tmrl/h registers while I run the program in the simulator. Regards P B Raju
  7. Yes, RTOS will give freedom to programmer handling multiple task at precise time(of course may be sacrificing some timer to do task switcing). I think it will be great convienience programming without bothering about the interrupt handling. for example :while I handle multiple peripherals like VFD modules(with simulates RS232) while communication interrupt occurs I have to handle both the communication with interrupt and it becomes complicated. I think things would have been easier if RTOS would have been implemented. Please plan to implement in future versions. Regards P B Raju
  8. Hmmm I don't see reference to any "error" in the warning related to delays. What makes you think it's an error? Regards, Pavel <{POST_SNAPBACK}> Ok thats not an error , just warning, but why? I have not used this function anywhwere? secondly I think at least multiply and divide should be supported in al thread. they are basic math operations to be performed. can you do something about it. Regards, P B Raju
  9. This is incorrect statement. You can call a function as many times as you want but from one thread (main or interrupt). Again you can call any function any times you want but from one thread (see above). Regards, Pavel <{POST_SNAPBACK}> does this also mean low priority interrupt and High priority interrupts run in different thread. regards P B Raju
  10. I face this problem very frequently: Warning: argument of 'delay_us' calls must have a value of 1 or more Function called in more than one execution thread: CmdToVFD I get this error while I call the functions more than 1 time. I remember last time you suggested that for such type of problem I should create same function with different name. but you can estimate that embeded devices dont have huge memory banks to use the space lavishly. we want a small code thats why we use functions and aviod repeated code writing and also prevent space occupied by the code. I think you need to fix this problem. once I have called a function and its work is over, there should be possibility of calling the function again. in this case I am not calling the function during its execution. Secondly see the delay_us I didnt use this function. Regards, P B Raju
  11. and what about delay_us , why this error when I have not used it. Not only in this I have previously been getting delay_us error even not using it.
  12. I get following error while I use mathematial operation on unsigned long and unsigned int types specially multiplication and division operation: Warning: argument of 'delay_us' calls must have a value of 1 or more Function called in more than one execution thread: __div_32_32 Please note I have not used any delay function in my program. can you tell me why this error occurs. I remove the particular function then there is no error. But I copy the same function(only) in a different program and run it, it compiles fine. I cant understand what is the problem, and how to avoid it? Please explain. Regards, P B Raju
  13. Thanks Stéphane, that resolved the problem I get the timer running correctly. Regards, P B Raju
  14. I think you need all the files to compile. here it is. source file : #include <system.h> #include "ConstDef.H" #include "GlobalVar.H" #include "VFD.H" #ifdef _PIC18 #pragma DATA _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H #pragma DATA _CONFIG2L, _BOR_OFF_2L & _PWRT_OFF_2L #pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H //#pragma DATA _CONFIG3H, _CCP2MX_ON_3H #pragma DATA _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L #pragma DATA _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L #pragma DATA _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H #pragma DATA _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L #pragma DATA _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H #pragma DATA _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L #pragma DATA _CONFIG7H, _EBTRB_OFF_7H #endif void ConfigurePriority(void); void ConfigureInterrrupt(void); void ConfigPort(void); void InitVar(void); void TempPortTest(void); uchar StrTmrl,StrTmrh; bit bit1; bit bit2; bit bit3; bit bit4; bit bit5; bit bit6; bit bit7; void main() { clear_bit(intcon,GIE); TempPortTest(); ConfigPort(); unsigned char i = 0; ConfigurePriority(); ConfigureInterrrupt(); t0con.TMR0ON = 1; while(1) { asm nop } //close while loop } //main looop close void ConfigPort(void) { trisa = 0x00; trisb = 0xF0; trisc = 0x00; trisd = 0x02; trise = 0x00; porta = 0x00; portb = 0x00; portc = 0x00; portd = 0x00; porte = 0x00; } void ConfigurePriority(void) { rcon = 0; ipr1 = 0; ipr2 = 0; ipr3 = 0; rcon.IPEN = 1; //Priority enabled on int intcon2.TMR0IP = 0; //TMR0 on low priority intcon2.RBIP = 0; //RB port change on low priority clear_bit(intcon,TMR0IF); ipr1.TXIP = 1; //Transmission on high priority. ipr1.RCIP = 1; //Reception on high priority. // pie1.TXIE = 1; //Transmission interrupt enabled. //pie1.RCIE = 1; } void ConfigureInterrrupt(void) { intcon2 = 0; intcon3 = 0; intcon = 0; pie1 = 0; pie2 = 0; pie3 = 0; //intcon.RBIE = 1; portb = 0xF0; intcon.RBIF = 0; //port change interrupt flag intcon2.NOT_RBPU = 0; //enable pull up on portB intcon.PEIE = 1; //necessary to prevent false counting intcon.GIE = 1; intcon.RBIF = 0; intcon.TMR0IE = 1; } void TempPortTest(void) { intcon.TMR0IF = 0; t0con = 0x00; t0con = 00000100b; ITemp = ConfigTmr(52,32,4); LOBYTE(Timer0LVal,ITemp); //tmr0l = 0xFF; //52 µSec timer load HIBYTE(Timer0HVal,ITemp); //tmr0h = 0x7D; tmr0l = Timer0LVal; tmr0h = Timer0HVal; set_bit(t0con,2); // = 0x01; //always write it here otherwise problem // t0con.TMR0ON = 1; //switch On Timer0 here } void interrupt(void) { asm nop if(RCIF) { } if(TXIF) { } } void interrupt_low() { //if((intcon & 0x04) && (intcon & 0x10)) //(TMR0IF) check timer0 interrupt if(TMR0IF) { VFD_Data = !VFD_Data; tmr0l = Timer0LVal; CTemp = tmr0l; tmr0h = Timer0HVal; clear_bit(intcon,TMR0IF); } //Timer0 close //PORTB change interrupt close clear_bit(intcon,TMR0IF); intcon.RBIF = 0 ; } //VFD.h ***********************port pin definitions*******************************/ bit VFD_Data@LATD.RD0; //pin 19 bit VFD_BusyTest@LATD.RD1; //input port to test whether data could be sent on the data line? 20 bit VFD_En@LATD.RD7; bit Test_Pin@LATB.RB0; //pin 33 bit Test_Pin1@LATB.RB1; //pin 34 bit Test_Pin2@LATB.RB2; //pin 35 bit Test_Pin3@LATB.RB3; //pin 36 bit Sens_Pin4@PORTB.RB4; //pin 37 bit Sens_Pin5@PORTB.RB5; //pin 38 bit Sens_Pin6@PORTB.RB6; //pin 39 bit Sens_Pin7@PORTB.RB7; //pin 40 /*********************** end *******************************/ /***********************VFD bit definitions*******************************/ bit VFD_Busy_Flag; bit VFD_Startbit_Flag; bit VFD_SingleByte_Flag; bit VFD_TxBit; bit VFD_BitLoad_Flag; /*********************** end ****************************/ /***********************Variable definitions*******************************/ uchar VFDBuffPointer = 0; //domt use it here and there , only use it in VFD disaply routine. uchar VFDBuffer[80]; /*********************** end ****************************/ unsigned char ShowMsgString(unsigned char pos,rom char *Msg,unsigned char e); void CmdToVFD(unsigned char cmd); uint ConfigTmr(uint MicroSecs,uchar PreScal,uchar Corr); void InitVFD() { ; } uchar ShowMsgString(uchar pos,rom char *Msg,uchar e) { uchar VFDStatus; if(!VFD_Busy_Flag) { CTemp = 0; VFDStatus = 0xFF; VFD_Busy_Flag = 1; VFDBuffPointer = pos; while((VFDBuffPointer < 80) || (Msg[CTemp])) { VFDBuffer[pos] = Msg[VFDBuffPointer]; VFDBuffPointer++; CTemp++; } VFDBuffPointer = 0; VFD_Startbit_Flag = 1; } else { VFDStatus = 0x00; } return(VFDStatus); } void CmdToVFD(unsigned char cmd) { if(!VFD_Busy_Flag) { VFD_SingleByte_Flag = 1; VFD_Busy_Flag = 1; VFD_Data = cmd; //load tx single byte data command VFD_TxBit = 0; //since transmission will beging straigt fater this routine load start bit } } uint BaudRateSet(unsigned short BaudRate) // Baud rate to be specified in removing last 2 zeros. { if(BaudRate >= 192) { txsta.BRGH = 1; //Low Speed LTemp = FOSC/(BaudRate * 16); ITemp = LTemp - 1; return ITemp; } else { txsta.BRGH = 0; //High Speed LTemp = FOSC/(BaudRate * 64); LTemp = LTemp - 1; return ITemp; } } uint ConfigTmr(uint MicroSecs,uchar PreScal,uchar Corr) //can define max 65mS time here { //correction factor needed to compensate interrupt latency ulong Temp; LTemp = FOSCby4/100; LTemp = LTemp * MicroSecs; LTemp = LTemp/PreScal; LTemp = LTemp/10000; LTemp = LTemp - Corr; if(LTemp < 0xFFFF) { MicroSecs = 0xFFFF - LTemp; } else MicroSecs = 0x00; return(MicroSecs); } //"ConstDef.H" #pragma CLOCK_FREQ 32000000 #define FOSC 32000000 #define FOSCby4 8000000 //calculate and define this byte here FOSC/4 typedef unsigned char uchar; typedef unsigned int uint; typedef unsigned long ulong; //GlobalVar.H uchar ErrorVal = 0; uchar BitCntr = 0; ulong LTemp = 0; uint ITemp = 0; uchar CTemp = 0,Timer0LVal = 0,Timer0HVal = 0;
×
×
  • Create New...